public Task <IPickedMediaFromGallery> PickVideoAsync() { UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (topController.PresentedViewController != null) { topController = topController.PresentedViewController; } _pickVideoTaskCompletion = new TaskCompletionSource <IPickedMediaFromGallery>(); UIImagePickerController imagePicker = new UIImagePickerController(); imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; imagePicker.MediaTypes = new string[] { UTType.Movie }; imagePicker.FinishedPickingMedia += (sender, args) => { IPickedMediaFromGallery result = null; try { string mediaTypeInfo = args.Info[UIImagePickerController.MediaType].ToString(); if (mediaTypeInfo == _MOVIE_MEDIA_TYPE) { result = HandlePickedMovie(args); } else { result = new PickedMediaFromGallery(); } } catch (Exception exc) { result = new PickedMediaFromGallery() { Exception = exc }; } topController.DismissModalViewController(true); _pickVideoTaskCompletion.SetResult(result); }; imagePicker.Canceled += (sender, args) => { topController.DismissModalViewController(true); _pickVideoTaskCompletion.SetResult(new PickedMediaFromGallery() { Completion = true }); }; topController.PresentModalViewController(imagePicker, true); return(_pickVideoTaskCompletion.Task); }
//public Task<string> GetPhotoAsync() { // string imageBase64 = null; // Task<string> task = new Task<string>(() => imageBase64); // try { // UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController; // while (topController.PresentedViewController != null) { // topController = topController.PresentedViewController; // } // // // // Action sheet // // // UIAlertController actionSheet = // UIAlertController.Create("Pick photo.", "Pick photo with:", UIAlertControllerStyle.ActionSheet); // // // // Photo galery action // // // actionSheet.AddAction(UIAlertAction.Create("Photo galery", UIAlertActionStyle.Default, (action) => { // UIImagePickerController imagePicker = new UIImagePickerController(); // imagePicker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary; // imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.PhotoLibrary); // imagePicker.FinishedPickingMedia += (sender, args) => { // if (args?.OriginalImage != null) { // // // // Figure out how much to scale down by // // // int inSampleSize = GetInSampleSize(args.OriginalImage.Size.Width, args.OriginalImage.Size.Height); // UIImage originalImage = args.OriginalImage.Scale(new CGSize(args.OriginalImage.Size.Width / inSampleSize, args.OriginalImage.Size.Height / inSampleSize)); // imageBase64 = originalImage.AsJPEG().GetBase64EncodedString(NSDataBase64EncodingOptions.EndLineWithLineFeed); // } // topController.DismissModalViewController(true); // task.Start(); // }; // imagePicker.Canceled += (sender, args) => { // topController.DismissModalViewController(true); // task.Start(); // }; // topController.PresentModalViewController(imagePicker, true); // })); // // // // Camera action // // // actionSheet.AddAction(UIAlertAction.Create("Camera", UIAlertActionStyle.Default, (action) => { // if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { // UIImagePickerController imagePicker = new UIImagePickerController(); // imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; // imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); // imagePicker.FinishedPickingMedia += (sender, args) => { // if (args?.OriginalImage != null) { // // // // Figure out how much to scale down by // // // int inSampleSize = GetInSampleSize(args.OriginalImage.Size.Width, args.OriginalImage.Size.Height); // UIImage originalImage = args.OriginalImage.Scale(new CGSize(args.OriginalImage.Size.Width / inSampleSize, args.OriginalImage.Size.Height / inSampleSize)); // imageBase64 = originalImage.AsJPEG().GetBase64EncodedString(NSDataBase64EncodingOptions.EndLineWithLineFeed); // } // topController.DismissModalViewController(true); // task.Start(); // }; // imagePicker.Canceled += (sender, args) => { // topController.DismissModalViewController(true); // task.Start(); // }; // topController.PresentModalViewController(imagePicker, true); // } // else { // UIAlertController alert = UIAlertController.Create("Warning", "Your device don't have camera", UIAlertControllerStyle.Alert); // alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (alertAction) => { // imageBase64 = null; // task.Start(); // })); // topController.PresentViewController(alert, true, null); // } // })); // UIPopoverPresentationController presentationPopover = actionSheet.PopoverPresentationController; // if (presentationPopover != null) { // presentationPopover.SourceView = topController.View; // presentationPopover.PermittedArrowDirections = UIPopoverArrowDirection.Up; // } // // // // Display the alert // // // topController.PresentViewController(actionSheet, true, null); // } // catch (Exception) { // imageBase64 = null; // task.Start(); // } // return task; //} public Task <string> GetPhotoAsync() { string imageBase64 = null; Task <string> task = new Task <string>(() => imageBase64); try { UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (topController.PresentedViewController != null) { topController = topController.PresentedViewController; } UIImagePickerController imagePicker = null; if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { imagePicker = new UIImagePickerController(); imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); imagePicker.FinishedPickingMedia += (sender, args) => { if (args?.OriginalImage != null) { // // Figure out how much to scale down by // int inSampleSize = GetInSampleSize(args.OriginalImage.Size.Width, args.OriginalImage.Size.Height); UIImage originalImage = args.OriginalImage.Scale(new CGSize(args.OriginalImage.Size.Width / inSampleSize, args.OriginalImage.Size.Height / inSampleSize)); imageBase64 = originalImage.AsJPEG().GetBase64EncodedString(NSDataBase64EncodingOptions.EndLineWithLineFeed); } topController.DismissModalViewController(true); task.Start(); }; imagePicker.Canceled += (sender, args) => { topController.DismissModalViewController(true); task.Start(); }; topController.PresentModalViewController(imagePicker, true); } } catch (Exception) { imageBase64 = null; task.Start(); } return(task); }
public override void MediaItemsPicked(MPMediaPickerController sender, MPMediaItemCollection mediaItemCollection) { var items = mediaItemCollection.Items; var assetUrl = items[0].AssetURL; //NSData data = NSData.FromUrl(assetUrl); //NSUrl soundFileURL = NSUrl.CreateFileUrl(@"%@/memo.mp3", assetUrl); ////[NSURL fileURLWithPathNSString stringWithFormat: @"%@/memo.m4a", documentsDirectory]]; ; //NSData myData = NSData.FromUrl(soundFileURL); GetAssetFromUrl(assetUrl); _viewController.DismissModalViewController(true); }
public override void CloseModalViewController() { if (_currentModalViewController != null) { _currentModalViewController.DismissModalViewController(true); _currentModalViewController = null; return; } base.CloseModalViewController(); }
/// <summary> /// Closes the modal view controller. /// </summary> public override void CloseModalViewController() { if (_currentModalViewController != null) { _currentModalViewController.DismissModalViewController(false); _currentModalViewController = null; } else { base.CloseModalViewController(); } }
public void Modal_3489() { using (UIViewController a = new UIViewController()) using (UIViewController b = new UIViewController()) using (UIViewController c = new UIViewController()) { a.PresentModalViewController(b, true); b.PresentModalViewController(c, true); b.DismissModalViewController(true); a.DismissModalViewController(true); //error } }
public void Bug3189() { using (UIViewController a = new UIViewController()) using (UIViewController b = new UIViewController()) using (UIViewController c = new UIViewController()) using (UIViewController wb = new UINavigationController(b)) using (UIViewController wc = new UINavigationController(c)) { a.PresentModalViewController(wb, true); b.PresentModalViewController(wc, true); c.DismissModalViewController(true); //error } }
public void Modal_3489() { using (UIViewController a = new UIViewController()) using (UIViewController b = new UIViewController()) using (UIViewController c = new UIViewController()) { a.PresentModalViewController(b, true); b.PresentModalViewController(c, true); #if XAMCORE_2_0 b.DismissModalViewController(true); a.DismissModalViewController(true); //error #else b.DismissModalViewControllerAnimated(true); a.DismissModalViewControllerAnimated(true); //error #endif } }
private static void HideViewController(UIViewController viewController) { if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { #pragma warning disable 618 // Disable DismissModalViewControllerAnimated warning, still need to support iOS 5 and older viewController.DismissModalViewController(true); #pragma warning restore 618 } else { // Dismiss view controller for iOS 6+ viewController.DismissViewController(true, delegate {}); } IsVisible = false; TouchPanel.EnabledGestures = prevGestures; }
public void Bug3189() { using (UIViewController a = new UIViewController()) using (UIViewController b = new UIViewController()) using (UIViewController c = new UIViewController()) using (UIViewController wb = new UINavigationController(b)) using (UIViewController wc = new UINavigationController(c)) { a.PresentModalViewController(wb, true); b.PresentModalViewController(wc, true); #if XAMCORE_2_0 c.DismissModalViewController(true); //error #else c.DismissModalViewControllerAnimated(true); //error #endif } }
public void SendTweet(string msg) { if (SLComposeViewController.IsAvailable(SLServiceKind.Twitter)) { var window = UIApplication.SharedApplication.KeyWindow; UIViewController vc = window.RootViewController; slComposer = SLComposeViewController.FromService(SLServiceKind.Twitter); slComposer.SetInitialText(msg); slComposer.CompletionHandler += (result) => { Device.BeginInvokeOnMainThread(() => { vc.DismissModalViewController(true); }); }; vc.PresentViewController(slComposer, true, null); } }
public void ItemSelected(UICollectionView collectionView, NSIndexPath indexPath) { var section = Sections[(int)indexPath.Section]; switch (section.Type) { case ImagePickerSection.CellType.SelectableImage: { var image = Sections[indexPath.Section].Images[(int)(indexPath.Item)]; bool isImageSelected = SelectedImages.Contains(image.Asset); if (isImageSelected) { UnselectImage(image.Asset, indexPath.Section); } else { SelectImageIfPossible(image.Asset, indexPath.Section); } var cell = collectionView.CellForItem(indexPath) as SelectableImageCollectionViewCell; cell.UpdateSelectedState(!isImageSelected, true); break; } case ImagePickerSection.CellType.TakePhoto: { var controller = new UIViewController(); controller.View.BackgroundColor = UIColor.White; var navigationController = new UINavigationController(controller); controller.NavigationItem.LeftBarButtonItem = new UIBarButtonItem("Cancel", UIBarButtonItemStyle.Plain, (sender, e) => { controller.DismissModalViewController(true); }); PresentModalViewController(navigationController, true); break; } } }
//public Task<IPickedMediaFromGallery> TakePhotoOrVideoAsync() => // Task<IPickedMediaFromGallery>.Run(() => { // PickedMediaFromGallery pickedMediaResult = new PickedMediaFromGallery(); // try { // UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController; // while (topController.PresentedViewController != null) { // topController = topController.PresentedViewController; // } // UIAlertController actionSheet = UIAlertController.Create("Make a choise", "Take Image or Video with:", UIAlertControllerStyle.ActionSheet); // /// // /// Use photo camera action // /// // actionSheet.AddAction(UIAlertAction.Create("Camera", UIAlertActionStyle.Default, (action) => { // if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { // UIImagePickerController imagePicker = new UIImagePickerController(); // imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; // imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); // imagePicker.FinishedPickingMedia += (sender, args) => { // if (args?.OriginalImage != null) { // /// // /// Figure out how much to scale down by // /// // int inSampleSize = GetInSampleSize(args.OriginalImage.Size.Width, args.OriginalImage.Size.Height); // UIImage originalImage = args.OriginalImage.Scale(new CGSize(args.OriginalImage.Size.Width / inSampleSize, args.OriginalImage.Size.Height / inSampleSize)); // string imageBase64 = originalImage.AsJPEG().GetBase64EncodedString(NSDataBase64EncodingOptions.EndLineWithLineFeed); // pickedMediaResult.Completion = true; // pickedMediaResult.DataBase64 = imageBase64; // pickedMediaResult.DataThumbnailBase64 = imageBase64; // pickedMediaResult.MimeType = ProfileMediaService.IMAGE_MEDIA_TYPE; // } // topController.DismissModalViewController(true); // }; // imagePicker.Canceled += (sender, args) => { // topController.DismissModalViewController(true); // pickedMediaResult.Completion = true; // }; // topController.PresentModalViewController(imagePicker, true); // } // else { // UIAlertController alert = UIAlertController.Create("Warning", "Your device don't have camera", UIAlertControllerStyle.Alert); // alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (alertAction) => { // pickedMediaResult.Completion = false; // pickedMediaResult.ErrorMessage = _TAKE_IMAGE_COMMON_ERROR; // })); // topController.PresentViewController(alert, true, null); // } // })); // /// // /// Use photo camera action // /// // //actionSheet.AddAction(UIAlertAction.Create("Video camera", UIAlertActionStyle.Default, (action) => { // // if (UIVide.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { // // UIImagePickerController imagePicker = new UIImagePickerController(); // // imagePicker.SourceType = UIImagePickerControllerSourceType.Camera; // // imagePicker.MediaTypes = UIImagePickerController.AvailableMediaTypes(UIImagePickerControllerSourceType.Camera); // // imagePicker.FinishedPickingMedia += (sender, args) => { // // if (args?.OriginalImage != null) { // // /// // // /// Figure out how much to scale down by // // /// // // int inSampleSize = GetInSampleSize(args.OriginalImage.Size.Width, args.OriginalImage.Size.Height); // // UIImage originalImage = args.OriginalImage.Scale(new CGSize(args.OriginalImage.Size.Width / inSampleSize, args.OriginalImage.Size.Height / inSampleSize)); // // string imageBase64 = originalImage.AsJPEG().GetBase64EncodedString(NSDataBase64EncodingOptions.EndLineWithLineFeed); // // pickedMediaResult.Completion = true; // // pickedMediaResult.DataBase64 = imageBase64; // // pickedMediaResult.DataThumbnailBase64 = imageBase64; // // pickedMediaResult.MimeType = ProfileMediaService.IMAGE_MEDIA_TYPE; // // } // // topController.DismissModalViewController(true); // // }; // // imagePicker.Canceled += (sender, args) => { // // topController.DismissModalViewController(true); // // pickedMediaResult.Completion = true; // // }; // // topController.PresentModalViewController(imagePicker, true); // // } // // else { // // UIAlertController alert = UIAlertController.Create("Warning", "Your device don't have camera", UIAlertControllerStyle.Alert); // // alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (alertAction) => { // // pickedMediaResult.Completion = false; // // pickedMediaResult.ErrorMessage = _TAKE_IMAGE_COMMON_ERROR; // // })); // // topController.PresentViewController(alert, true, null); // // } // //})); // } // catch (Exception exc) { // pickedMediaResult.Completion = false; // pickedMediaResult.Exception = exc; // pickedMediaResult.ErrorMessage = _TAKE_MEDIA_COMMON_ERROR; // } // return (IPickedMediaFromGallery)pickedMediaResult; // }); public Task <IPickedMediaFromGallery> TakePhotoOrVideoAsync() { _takeVideoOrImageTaskCompletion = new TaskCompletionSource <IPickedMediaFromGallery>(); try { UIViewController topController = UIApplication.SharedApplication.KeyWindow.RootViewController; while (topController.PresentedViewController != null) { topController = topController.PresentedViewController; } IMediaPickerService mediaPickerService = ViewModelLocator.Resolve <IMediaPickerService>(); UIAlertController actionSheet = UIAlertController.Create("Make a choise", "Take Image or Video with:", UIAlertControllerStyle.ActionSheet); /// /// Use photo camera action /// actionSheet.AddAction(UIAlertAction.Create("Camera", UIAlertActionStyle.Default, async(action) => { if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { try { MediaFile mediaFile = await mediaPickerService.TakePhotoAsync(); if (mediaFile != null) { string base64 = await mediaPickerService.ParseStreamToBase64(mediaFile.GetStream()); _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { Completion = true, DataBase64 = base64, MimeType = ProfileMediaService.IMAGE_MEDIA_TYPE, DataThumbnailBase64 = base64 }); mediaFile.Dispose(); } else { _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { Completion = true }); } } catch (Exception exc) { _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { ErrorMessage = _TAKE_IMAGE_COMMON_ERROR, Exception = exc }); } topController.DismissModalViewController(true); } else { UIAlertController alert = UIAlertController.Create("Warning", "Your device don't have camera", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (alertAction) => _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { ErrorMessage = _TAKE_IMAGE_COMMON_ERROR }))); topController.PresentViewController(alert, true, null); } })); /// /// Use photo camera action /// actionSheet.AddAction(UIAlertAction.Create("Video camera", UIAlertActionStyle.Default, async(action) => { if (UIImagePickerController.IsSourceTypeAvailable(UIImagePickerControllerSourceType.Camera)) { try { MediaFile mediaFile = await mediaPickerService.TakeVideoAsync(); if (mediaFile != null) { string thumbnailBase64 = await mediaPickerService.ParseStreamToBase64(GetThumbnail(mediaFile.Path)); string base64 = await mediaPickerService.ParseStreamToBase64(mediaFile.GetStream()); _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { Completion = true, DataBase64 = base64, MimeType = ProfileMediaService.VIDEO_MEDIA_TYPE, DataThumbnailBase64 = thumbnailBase64 }); mediaFile.Dispose(); } else { _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { Completion = true }); } } catch (Exception exc) { _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { ErrorMessage = _TAKE_IMAGE_COMMON_ERROR, Exception = exc }); } topController.DismissModalViewController(true); } else { UIAlertController alert = UIAlertController.Create("Warning", "Your device don't have camera", UIAlertControllerStyle.Alert); alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, (alertAction) => _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { ErrorMessage = _TAKE_IMAGE_COMMON_ERROR }))); topController.PresentViewController(alert, true, null); } })); topController.PresentViewController(actionSheet, true, null); } catch (Exception exc) { _takeVideoOrImageTaskCompletion.SetResult(new PickedMediaFromGallery() { Exception = exc, ErrorMessage = _TAKE_VIDEO_COMMON_ERROR }); } return(_takeVideoOrImageTaskCompletion.Task); }
/// <summary> /// closes the screen. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void CloseScreen(object sender, EventArgs e) { Screen.DismissModalViewController(false); }
/// <summary> /// closes the screen. /// </summary> /// <param name="sender">Sender.</param> /// <param name="e">E.</param> void CloseScreen(object sender, EventArgs e) { //close the button settings modal back to the main screen Screen.DismissModalViewController(false); }
public override void ViewDidLoad() { base.ViewDidLoad(); UpdateSettingsToggles(); // Perform any additional setup after loading the view, typically from a nib. this.View.BackgroundColor = UIColor.White; /* * Create the Alert View effect by changeing the background(parent) color and alpha. */ TopMostParent = PresentingViewController; TopMostParent.View.BackgroundColor = UIColor.Gray; TopMostParent.View.Alpha = 0.3f; CancelSessionButton.TouchUpInside += (sender, e) => { /* * Restore the default View effect by changeing the background(parent) color and alpha * as well as close the Modal Presentation controller. * */ TopMostParent.View.BackgroundColor = UIColor.White; TopMostParent.View.Alpha = 1.0f; TopMostParent.DismissModalViewController(true); }; StartSessionButton.TouchUpInside += (sender, e) => { //new UIAlertView("Start", null, null, "Ok", null).Show(); //FinishScreenController finishedScreen = new FinishScreenController(tabBar); FinishScreenController finishedScreen = new FinishScreenController(tabBar, SessionSource, runsTableViewController, imageTableViewController, CurrentProfile, CurrentCategory); SessionController RunSession = new SessionController(CurrentProfile, CurrentCategory, finishedScreen); finishedScreen.ReturnSessionData += (CurrentSession currentSession, int Attempted, int Correct) => { //add the results to the database if (CurrentProfile != null) //Valid Profile { //create the session Session newSession = new Session(); newSession.SessionDate = DateTime.Now.ToString("d"); newSession.ParentProfileID = CurrentProfile.ID; //newSession.SessionScore = Attempted / Correct * 1.0; newSession.Attempted = Attempted; newSession.Correct = Correct; newSession.CategoryID = CurrentCategory.ID; int insertResult = new DatabaseContext <Session>().Insert(newSession); //submit the results to that database foreach (Result res in currentSession.SessionResultsList) { SessionResult temp = new SessionResult(); temp.ParentSessionID = newSession.ID; temp.SessionImageID = res.ResultImageID; temp.categoryID = CurrentCategory.ID; if (res.ImageIncorrect) { temp.Missed = true; temp.ResultString = "M"; } else if (res.ImageIndependent) { temp.Independent = true; temp.ResultString = "I"; } else { temp.Prompted = true; temp.ResultString = "P"; } new DatabaseContext <SessionResult>().Insert(temp); } //update the profile with the lates date CurrentProfile.LastSessionDate = DateTime.Now.ToString("d"); new DatabaseContext <Profiles>().Update(CurrentProfile); } }; RunSession.ModalPresentationStyle = UIModalPresentationStyle.OverCurrentContext; RunSession.ModalTransitionStyle = UIModalTransitionStyle.CrossDissolve; //parent TopMostParent.DismissModalViewController(true); TopMostParent.View.BackgroundColor = UIColor.White; TopMostParent.View.Alpha = 1.0f; TopMostParent.PresentViewController(RunSession, true, null); }; DisplayLabelsToggle.ValueChanged += (sender, e) => { //get toggle switch state if (DisplayLabelsToggle.On) { //new UIAlertView("Toggle On", null, null, "Ok", null).Show(); CurrentProfile.showLabelSettings = true; new DatabaseContext <Profiles>().Update(CurrentProfile); } else { //new UIAlertView("Toggle Off", null, null, "Ok", null).Show(); CurrentProfile.showLabelSettings = false; new DatabaseContext <Profiles>().Update(CurrentProfile); } }; DisplayPictureToggle.ValueChanged += (sender, e) => { //get toggle switch state if (DisplayPictureToggle.On) { //new UIAlertView("Toggle On", null, null, "Ok", null).Show(); CurrentProfile.showImageSettings = true; new DatabaseContext <Profiles>().Update(CurrentProfile); } else { //new UIAlertView("Toggle Off", null, null, "Ok", null).Show(); CurrentProfile.showImageSettings = false; new DatabaseContext <Profiles>().Update(CurrentProfile); } }; }
private static void HideViewController(UIViewController viewController) { if (!UIDevice.CurrentDevice.CheckSystemVersion(6, 0)) { #pragma warning disable 618 // Disable DismissModalViewControllerAnimated warning, still need to support iOS 5 and older viewController.DismissModalViewController(true); #pragma warning restore 618 } else { // Dismiss view controller for iOS 6+ viewController.DismissViewController(true, delegate {}); } IsVisible = false; TouchPanel.EnabledGestures = prevGestures; }