当前位置: 首页>>代码示例>>C#>>正文


C# NSUrl类代码示例

本文整理汇总了C#中NSUrl的典型用法代码示例。如果您正苦于以下问题:C# NSUrl类的具体用法?C# NSUrl怎么用?C# NSUrl使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NSUrl类属于命名空间,在下文中一共展示了NSUrl类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: FromUrl

        public static UIImage FromUrl(string uri)
        {
            var imageName = uri.Substring(uri.LastIndexOf ('/') + 1);

            if (File.Exists (Path.Combine (NativeImagesPath, imageName)))
                return UIImage.FromFile (Path.Combine (NativeImagesPath, imageName));

            if (File.Exists (Path.Combine (ImagesCachePath, imageName)))
                return UIImage.FromFile (Path.Combine (ImagesCachePath, imageName));

            if (Items.ContainsKey (uri))
                return Items [uri];

            using (var url = new NSUrl (uri))
            using (var data = NSData.FromUrl (url)) {
                var image = UIImage.LoadFromData (data);

                if (!NSFileManager.DefaultManager.FileExists (ImagesCachePath))
                    NSFileManager.DefaultManager.CreateDirectory (ImagesCachePath, false, null);

                var result = NSFileManager.DefaultManager.CreateFile (Path.Combine (ImagesCachePath, imageName), data, new NSFileAttributes ());
                if (!result)
                    Items [uri] = image;

                return image;
            }
        }
开发者ID:jokio,项目名称:jok-shared-ios,代码行数:27,代码来源:ImagesCache.cs

示例2: AddBarButtonText

        public void AddBarButtonText(object sender, EventArgs e)
        {
            var nativeTextField = Control as UITextField;

            NSUrl url = new NSUrl ("tel:" + nativeTextField.Text);
            UIApplication.SharedApplication.OpenUrl (url);
        }
开发者ID:irfannuri,项目名称:dial-at-once,代码行数:7,代码来源:DialSearchEntryRenderer.cs

示例3: Donate

 public void Donate()
 {
     using (NSUrl url = new NSUrl(_paypalUrl))
     {
         UIApplication.SharedApplication.OpenUrl(url);
     }
 }
开发者ID:jonathanpeppers,项目名称:uController,代码行数:7,代码来源:AboutController.cs

示例4: Create

        public static BaseItemView Create (CGRect frame, NodeViewController nodeViewController, TreeNode node, string filePath, UIColor kleur)
        {
            var view = BaseItemView.Create(frame, nodeViewController, node, kleur);
            UIWebView webView = new UIWebView();

			string extension = Path.GetExtension (filePath);
			if (extension == ".odt") {
				string viewerPath = NSBundle.MainBundle.PathForResource ("over/viewer/index", "html");

				Uri fromUri = new Uri(viewerPath);
				Uri toUri = new Uri(filePath);
				Uri relativeUri = fromUri.MakeRelativeUri(toUri);
				String relativePath = Uri.UnescapeDataString(relativeUri.ToString());

				NSUrl finalUrl = new NSUrl ("#" + relativePath.Replace(" ", "%20"), new NSUrl(viewerPath, false));
				webView.LoadRequest(new NSUrlRequest(finalUrl));
				webView.ScalesPageToFit = true;
				view.ContentView = webView;

				return view;
			} else {
				NSUrl finalUrl = new NSUrl (filePath, false);
				webView.LoadRequest(new NSUrlRequest(finalUrl));
				webView.ScalesPageToFit = true;
				view.ContentView = webView;

				return view;
			}
		
        }
开发者ID:MBrekhof,项目名称:pleiobox-clients,代码行数:30,代码来源:WebItemView.cs

示例5: PdfViewController

		public PdfViewController (NSUrl url) : base()
		{
			Url = url;
			View = new UIView ();
			View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight | UIViewAutoresizing.FlexibleTopMargin | UIViewAutoresizing.FlexibleBottomMargin | UIViewAutoresizing.FlexibleLeftMargin | UIViewAutoresizing.FlexibleRightMargin;
			View.AutosizesSubviews = true;
			
			PdfDocument = CGPDFDocument.FromUrl (Url.ToString ());
			
			// For demo purposes, show first page only.
			PdfPage = PdfDocument.GetPage (1);
			PdfPageRect = PdfPage.GetBoxRect (CGPDFBox.Crop);
			
			// Setup tiled layer.
			TiledLayer = new CATiledLayer ();
			TiledLayer.Delegate = new TiledLayerDelegate (this);
			TiledLayer.TileSize = new SizeF (1024f, 1024f);
			TiledLayer.LevelsOfDetail = 5;
			TiledLayer.LevelsOfDetailBias = 5;
			TiledLayer.Frame = PdfPageRect;
			
			ContentView = new UIView (PdfPageRect);
			ContentView.Layer.AddSublayer (TiledLayer);
			
			// Prepare scroll view.
			ScrollView = new UIScrollView (View.Frame);
			ScrollView.AutoresizingMask = View.AutoresizingMask;
			ScrollView.Delegate = new ScrollViewDelegate (this);
			ScrollView.ContentSize = PdfPageRect.Size;
			ScrollView.MaximumZoomScale = 10f;
			ScrollView.MinimumZoomScale = 1f;
			ScrollView.ScrollEnabled = true;
			ScrollView.AddSubview (ContentView);
			View.AddSubview (ScrollView);
		}
开发者ID:21Off,项目名称:21Off,代码行数:35,代码来源:PdfViewController.cs

示例6: GetCell

        public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            ShopsTableCell cell = new ShopsTableCell(cellIdentifier);
            try
            {
                cell = tableView.DequeueReusableCell(cellIdentifier) as ShopsTableCell;

                if (cell == null)
                    cell = new ShopsTableCell(cellIdentifier);
                if (!String.IsNullOrEmpty(tableItems[indexPath.Row].FirstPhotoUrl))
                {
                    NSUrl nsUrl = new NSUrl(tableItems[indexPath.Row].FirstPhotoUrl);
                    NSData data = NSData.FromUrl(nsUrl);

                    if (data != null)
                        cell.UpdateCell(tableItems[indexPath.Row].Name, tableItems[indexPath.Row].Description, tableItems[indexPath.Row].Price.ToString("N2"), new UIImage(data));
                    else
                        cell.UpdateCell(tableItems[indexPath.Row].Name, tableItems[indexPath.Row].Description, tableItems[indexPath.Row].Price.ToString("N2"), new UIImage());
                }
                else
                    cell.UpdateCell(tableItems[indexPath.Row].Name, tableItems[indexPath.Row].Description, tableItems[indexPath.Row].Price.ToString("N2"), new UIImage());

                OnGotCell();
                CellOn = indexPath.Row;
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
            return cell;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:31,代码来源:ShopsTableView.cs

示例7: StartProvidingItemAtUrl

		public override void StartProvidingItemAtUrl (NSUrl url, Action<NSError> completionHandler)
		{
			Console.WriteLine ("FileProvider StartProvidingItemAtUrl");

			// When this method is called, your extension should begin to download,
			// create, or otherwise make a local file ready for use.
			// As soon as the file is available, call the provided completion handler.
			// If any errors occur during this process, pass the error to the completion handler.
			// The system then passes the error back to the original coordinated read.

			NSError error, fileError = null;

			string str = "These are the contents of the file";
			NSData fileData = ((NSString)str).Encode (NSStringEncoding.UTF8);

			Console.WriteLine ("FileProvider before CoordinateWrite url {0}", url);
			FileCoordinator.CoordinateWrite (url, 0, out error, (newUrl) => {
				Console.WriteLine ("before data save");
				fileData.Save (newUrl, 0, out fileError);
				Console.WriteLine ("data saved");
			});
			Console.WriteLine ("FileProvider after CoordinateWrite");
			Console.WriteLine ("FileProvider CoordinateWrite error {0}", error);

			completionHandler (error ?? fileError);
		}
开发者ID:b-theile,项目名称:monotouch-samples,代码行数:26,代码来源:FileProvider.cs

示例8: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			UIBarButtonItem home = new UIBarButtonItem();
			home.Style = UIBarButtonItemStyle.Plain;
			home.Target = this;
			home.Image = UIImage.FromFile("Images/home.png");
			this.NavigationItem.RightBarButtonItem = home;
			UIViewController[] vistas = NavigationController.ViewControllers;
			home.Clicked += (sender, e) => {
				this.NavigationController.PopToViewController(vistas[0], true);
			};
			
			this.lblTitulo.Text = this.noticia.titulo;
			try{
				NSUrl nsUrl = new NSUrl (this.noticia.imagen);
				NSData data = NSData.FromUrl (nsUrl);
				this.imgNoticia.Image = UIImage.LoadFromData (data);
			}catch(Exception){
				this.imgNoticia.Image = Images.sinImagen;
			}
			if(UIDevice.CurrentDevice.UserInterfaceIdiom == UIUserInterfaceIdiom.Phone){
				this.txtDescripcion.Font = UIFont.SystemFontOfSize(10);
			}else{
				this.txtDescripcion.Font = UIFont.SystemFontOfSize(30);
			}
			this.txtDescripcion.Text = this.noticia.descripcion;
		}
开发者ID:saedaes,项目名称:ProductFinder,代码行数:29,代码来源:NewsDetailView.cs

示例9: CopyToDocumentsDirectoryAsync

        public static Task<NSUrl> CopyToDocumentsDirectoryAsync(NSUrl fromUrl)
        {
            var tcs = new TaskCompletionSource<NSUrl>();

            NSUrl localDocDir = GetDocumentDirectoryUrl ();
            NSUrl toURL = localDocDir.Append (fromUrl.LastPathComponent, false);

            bool success = false;
            NSError coordinationError, copyError = null;
            NSFileCoordinator fileCoordinator = new NSFileCoordinator ();

            ThreadPool.QueueUserWorkItem (_ => {
                fileCoordinator.CoordinateReadWrite (fromUrl, 0, toURL, NSFileCoordinatorWritingOptions.ForReplacing, out coordinationError, (src, dst) => {
                    NSFileManager fileManager = new NSFileManager();
                    success = fileManager.Copy(src, dst, out copyError);

                    if (success) {
                        var attributes = new NSFileAttributes {
                            ExtensionHidden = true
                        };
                        fileManager.SetAttributes (attributes, dst.Path);
                        Console.WriteLine ("Copied file: {0} to: {1}.", src.AbsoluteString, dst.AbsoluteString);
                    }
                });

                // In your app, handle this gracefully.
                if (!success)
                    Console.WriteLine ("Couldn't copy file: {0} to: {1}. Error: {2}.", fromUrl.AbsoluteString,
                        toURL.AbsoluteString, (coordinationError ?? copyError).Description);

                tcs.SetResult(toURL);
            });

            return tcs.Task;
        }
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:35,代码来源:ResourceHelper.cs

示例10: LoadAlbumInformation

		private void LoadAlbumInformation ()
		{
			var albumUrlPath = "http://api.dribbble.com/" + _apiPath; 

			// Nimbus processors allow us to perform complex computations on a separate thread before
			// returning the object to the main thread. This is useful here because we perform sorting
			// operations and pruning on the results.
			var url = new NSUrl (albumUrlPath);
			var request = new NSMutableUrlRequest (url);

//			public delegate void ImageRequestOperationWithRequestSuccess1(UIImage image);
//			public delegate void ImageRequestOperationWithRequestSuccess2(NSUrlRequest request, NSHttpUrlResponse response, UIImage image);
//			public delegate void ImageRequestOperationWithRequestFailure(NSUrlRequest request, NSHttpUrlResponse response, NSError error);
//			public delegate UIImage ImageRequestOperationWithRequestProcessingBlock(UIImage image);
//			public delegate void AFJSONRequestOperationJsonRequestOperationWithRequestSuccess(NSUrlRequest request, NSHttpUrlResponse response, NSObject json);
//			public delegate void AFJSONRequestOperationJsonRequestOperationWithRequestFailure(NSUrlRequest request, NSHttpUrlResponse response, NSError error, NSObject json);
//			[BaseType (typeof (AFHTTPRequestOperation))]

			var albumRequest = AFJSONRequestOperation.JsonRequestOperationWithRequest (request, 
			                                                                           (req, res, json) => {
				BlockForAlbumProcessing (req, res, (NSDictionary)json);
			}, (req, resp, error, json) => {
				Console.WriteLine ("Error");
			});

			Queue.AddOperation (albumRequest);
		}
开发者ID:pauldotknopf,项目名称:MonoTouch.Nimbus,代码行数:27,代码来源:DribblePhotoAlbumViewController.cs

示例11: GetCell

        public override UITableViewCell GetCell(UITableView tableView, MonoTouch.Foundation.NSIndexPath indexPath)
        {
            EventsTableCell cell = new EventsTableCell(cellIdentifier);
            try
            {
                cell = tableView.DequeueReusableCell(cellIdentifier) as EventsTableCell;

                if (cell == null)
                    cell = new EventsTableCell(cellIdentifier);
                string dt = tableItems[indexPath.Row].StartDate.ToString("d/MM") +" "+ tableItems[indexPath.Row].StartDate.ToLocalTime().ToShortTimeString() + " @ " + tableItems[indexPath.Row].Location;
                if (!String.IsNullOrEmpty(tableItems[indexPath.Row].LogoUrl))
                {
                    NSUrl nsUrl = new NSUrl(tableItems[indexPath.Row].LogoUrl);
                    NSData data = NSData.FromUrl(nsUrl);

                    if (data != null)
                        cell.UpdateCell(tableItems[indexPath.Row].Name, dt, new UIImage(data));
                    else
                        cell.UpdateCell(tableItems[indexPath.Row].Name, dt, new UIImage());
                }
                else
                    cell.UpdateCell(tableItems[indexPath.Row].Name, dt, new UIImage());

                OnGotCell();
                CellOn = indexPath.Row;
            }
            catch (Exception exception)
            {
                ErrorHandler.Save(exception, MobileTypeEnum.iPhone);
            }
            return cell;
        }
开发者ID:mukhtiarlander,项目名称:git_demo_torit,代码行数:32,代码来源:EventsTableView.cs

示例12: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			if (ArchitectView.IsDeviceSupported (AugmentedRealityMode.Geo))
			{
				arView = new ArchitectView (UIScreen.MainScreen.Bounds);
				View = arView;
			
				arView.SetLicenseKey ("YOUR-LICENSE-KEY");

				var absoluteWorldUrl = WorldOrUrl;

				if (!IsUrl)
					absoluteWorldUrl = NSBundle.MainBundle.BundleUrl.AbsoluteString + "ARchitectExamples/" + WorldOrUrl + "/index.html";

				var u = new NSUrl (absoluteWorldUrl);
				
				arView.LoadArchitectWorld (u);

			}
			else
			{
				var adErr = new UIAlertView ("Unsupported Device", "This device is not capable of running ARchitect Worlds. Requirements are: iOS 5 or higher, iPhone 3GS or higher, iPad 2 or higher. Note: iPod Touch 4th and 5th generation are only supported in WTARMode_IR.", null, "OK", null);
				adErr.Show ();
			}
		}
开发者ID:Redth,项目名称:Wikitude.Xamarin,代码行数:27,代码来源:ARViewController.cs

示例13: ViewDidLoad

		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();
			// Perform any additional setup after loading the view, typically from a nib.
			string translatedNumber = "";

			translateBtn.TouchUpInside += (object sender, EventArgs e) => {
				translatedNumber = PhoneTranslator.ToNumber(phoneNumberText.Text);

				phoneNumberText.ResignFirstResponder();

				if(translatedNumber == "")
				{
					callBtn.SetTitle("Call", UIControlState.Normal);
					callBtn.Enabled = false;
				}
				else
				{
					callBtn.SetTitle("Call " + translatedNumber, UIControlState.Normal);
					callBtn.Enabled = true;
				}
			};

			callBtn.TouchUpInside += (object sender, EventArgs e) => {
				var url = new NSUrl("tel:" + translatedNumber);

				if(!UIApplication.SharedApplication.OpenUrl(url))
				{
					var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
					alert.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, null));
					PresentViewController(alert, true, null);
				}
			};
		}
开发者ID:Kethsar,项目名称:CS235IM,代码行数:34,代码来源:ViewController.cs

示例14: ImageLoaderStringElement

 public ImageLoaderStringElement(string caption,  NSAction tapped, NSUrl imageUrl, UIImage placeholder)
     : base(caption, tapped)
 {
     Placeholder = placeholder;
     ImageUrl = imageUrl;
     this.Accessory = UITableViewCellAccessory.None;
 }
开发者ID:svrooij,项目名称:monotouch-bindings,代码行数:7,代码来源:ImageLoaderElement.cs

示例15: ViewDidLoad

        public override void ViewDidLoad()
        {
            base.ViewDidLoad ();

            if ( UIDevice.CurrentDevice.CheckSystemVersion(7, 0) )
            {
                EdgesForExtendedLayout = UIRectEdge.None;
            }

            if (WTArchitectView.IsDeviceSupportedForAugmentedRealityMode (WTAugmentedRealityMode._Geo))
            {
                arView = new WTArchitectView (UIScreen.MainScreen.Bounds, null, WTAugmentedRealityMode._Geo);
                arView.SetLicenseKey ("Ug7LmdNQJKN5AX85OMRGt1LIk1xBmwOWi8u+4eEVBpIvKZ8EWh2w1z3f5Cd4YHnWlEIdazY1envd/W7Xy5U4GUlkNmH2l9ddWZr5gIsz0zuD4GZVunmt0o49f4rDv+ssM78CAklidZeMkxqTGGoG6I8UjoegiWEKtzoH3qWpruNTYWx0ZWRfX3mWnNyLFq5Z+rfkc+m7sBeEhO/Urh2wYX/E57J6MdWPrCvmW0Zrt0RfAkUjmmHZ9MdjOyghN4VtSnY6nwc+Xz2Wg8vrCG02TIMw8SbNBRqP4ljrg3BnmjSONHRC69rzLnzCalB+YXAIdh5QdZI8TG8nJNUQCZGmjdrF5SpznSbcLpjDqfI36NaGW3cnH6evloXrcItbrnJDeeZlfB7CZj6PpLaf6q4GpKJRIEiVbeY3UpQ19+5IsydEbo0eVwZQFtE/G/NB7mNM1SjwteJ53EumNT9hd/4fMmk7L3nUj4kpyZ2gttPTS0/1kxtwVJjfRntngMiSN6czJrmrI5IyqN3qjEDextUNJ6zpvj97Vx/k+6RkItCgbMLZzdGgnyvIq9jumKiICOZXcFz4iacFFsYag4w87FoUwJFdp2SAsuW374FdmMB2tE5Zk5CONbQvMCKkMwdT6RnqA0SrzX4NA9qDLv8DwcoOu3jiszRE//8uOGS26I4NIznQniu8gn04sdeDm3P50rVkB7Vq3CDP89LIE8CoqChJ9DVEm2IzwfHFRd6cDalxC9szRKxOI4H5Z6wJY4tPHTeQha3Gp4jFQXLbtwfPLPcr+DyH8GkOf6+aIbzz3AVZZz9v67JN2W5O1xR2BZXAjkE0SC4zXK2g0H6MuDEYLdLHZCnl8ik/Aw3ydyFe5zw9+olNC/72uH5rA5ZLyiACVauyXwwsc6bNzJu3c5Dyb724zg==");

                var absoluteWorldUrl = WorldOrUrl;
                if (!IsUrl)
                    absoluteWorldUrl = NSBundle.MainBundle.BundleUrl.AbsoluteString + "ARchitectExamples/" + WorldOrUrl + "/index.html";
                Console.WriteLine (absoluteWorldUrl);
                var u = new NSUrl (absoluteWorldUrl);
                arView.LoadArchitectWorldFromUrl (u);

                View.AddSubview (arView);
            }
            else
            {
                var adErr = new UIAlertView ("Unsupported Device", "This device is not capable of running ARchitect Worlds. Requirements are: iOS 5 or higher, iPhone 3GS or higher, iPad 2 or higher. Note: iPod Touch 4th and 5th generation are only supported in WTARMode_IR.", null, "OK", null);
                adErr.Show ();
            }
        }
开发者ID:Wikitude,项目名称:wikitude-xamarin,代码行数:29,代码来源:ARViewController.cs


注:本文中的NSUrl类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。