/// <summary> /// Open Instagram with the specified image and caption. /// </summary> /// <returns><c>true</c> if Instagram is installed, <c>false</c> otherwise.</returns> /// <param name="image">Image.</param> /// <param name="caption">Caption.</param> public static bool Instagram(UIImage image, string caption = null) { if (!UIApplication.SharedApplication().CanOpenURL(new NSURL("instagram://app"))) { return(false); } // write image to tmp folder NSData data = image.JPEGRepresentation(1f); string filePath = Application.temporaryCachePath + "/" + UUID.Generate() + ".igo"; data.WriteToFile(filePath, true); _documentIC = UIDocumentInteractionController.InteractionController(new NSURL(filePath, false)); _documentIC.UTI = "com.instagram.exclusivegram"; if (caption != null) { var annotation = new Dictionary <object, object>(); annotation["InstagramCaption"] = caption; _documentIC.annotation = annotation; } var rootView = UIApplication.deviceRootViewController.view; _documentIC.PresentOpenInMenu(new Rect(0, 0, 1, 1), rootView, true); return(true); }
public void Load() { if (_webview == null) { // figure out parent UIView parentView = null; if ((UIApplication.deviceRootViewController != null) && (UIApplication.deviceRootViewController.view != null)) { parentView = UIApplication.deviceRootViewController.view; } else { parentView = UIApplication.SharedApplication().keyWindow; } // create view if (fullScreen) { _webview = new UIWebView(parentView.bounds); } else { _webview = new UIWebView(locationAndSize); } // add it to parent parentView.AddSubview(_webview); this.setURL(homeURL); } }
public void Show(string text) { // figure out parent UIView parentView = null; if ((UIApplication.deviceRootViewController != null) && (UIApplication.deviceRootViewController.view != null)) parentView = UIApplication.deviceRootViewController.view; else parentView = UIApplication.SharedApplication().keyWindow; var frame = parentView.bounds; // create view if (_activityView == null) { _activityView = new UIView(frame); _activityView.alpha = 0.8f; _activityView.backgroundColor = UIColor.BlackColor(); _activityIndicator = new UIActivityIndicatorView(UIActivityIndicatorViewStyle.WhiteLarge); _activityIndicator.hidesWhenStopped = false; _activityView.AddSubview(_activityIndicator); _activityLabel = new UILabel(frame); _activityLabel.textAlignment = NSTextAlignment.Center; _activityLabel.backgroundColor = UIColor.ClearColor(); _activityLabel.textColor = UIColor.WhiteColor(); _activityLabel.numberOfLines = 2; _activityView.AddSubview(_activityLabel); } // re-set frames _activityView.frame = frame; var indiFrame = _activityIndicator.frame; indiFrame.x = frame.width / 2 - indiFrame.width / 2; indiFrame.y = frame.height / 2 - indiFrame.height / 2; _activityIndicator.frame = indiFrame; var labelFrame = new Rect(0, indiFrame.yMax, frame.width, indiFrame.height * 2); _activityLabel.frame = labelFrame; _activityLabel.text = text; // add it to parent if (_activityView.superview == null) { _activityIndicator.StartAnimating(); parentView.AddSubview(_activityView); } }
void Start() { _webview = new UIWebView(locationAndSize); UIApplication.SharedApplication().keyWindow.rootViewController.view.AddSubview(_webview); // SayStuff is an offline html file under the Resources/ folder of Unity string html = (Resources.Load("SayStuff") as TextAsset).text; Debug.Log("HTML: " + html); _webview.LoadHTMLString(html, null); _webViewDelegate = new WebViewDelegate(); _webview.Delegate = _webViewDelegate; _webview.backgroundColor = UIColor.ClearColor(); _webview.opaque = false; }