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


C# UIViewController.PresentViewController方法代码示例

本文整理汇总了C#中UIViewController.PresentViewController方法的典型用法代码示例。如果您正苦于以下问题:C# UIViewController.PresentViewController方法的具体用法?C# UIViewController.PresentViewController怎么用?C# UIViewController.PresentViewController使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在UIViewController的用法示例。


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

示例1: DoTransition

        private void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel, UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

//            if (toViewController is SettingsViewController)
//            {
//                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(CodeFramework.iOS.Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
//                toViewDismissCommand.Subscribe(__ => toViewController.DismissViewController(true, null));
//                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
//            }
            if (toViewController is AccountsView)
            {
                var rootNav = (UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController;
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(Images.Cancel, UIBarButtonItemStyle.Plain, (s, e) => toViewDismissCommand.ExecuteIfCan());
                toViewDismissCommand.Subscribe(_ => rootNav.DismissViewController(true, null));
                rootNav.PresentViewController(new UINavigationController(toViewController), true, null);
            }
//            else if (fromViewController is RepositoriesViewController)
//            {
//                fromViewController.NavigationController.PresentViewController(toViewController, true, null);
//            }
            else if (toViewController is MenuView)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.Window.RootViewController);
                var slideout = new SlideoutNavigationController();
                slideout.MenuViewController = new MenuNavigationController(toViewController, slideout);
                UIView.Transition(nav.View, 0.1, UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(slideout, false), null);
            }
            else if (toViewController is NewAccountView && fromViewController is StartupView)
            {
                toViewDismissCommand.Subscribe(_ => toViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (fromViewController is MenuView)
            {
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
            else if (toViewController is LanguagesView && fromViewController is RepositoriesTrendingView)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(_ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
开发者ID:nelsonnan,项目名称:CodeHub,代码行数:52,代码来源:TransitionOrchestrationService.cs

示例2: DoTransition

        private static void DoTransition(UIViewController fromViewController, IBaseViewModel fromViewModel,
            UIViewController toViewController, IBaseViewModel toViewModel)
        {
            var toViewDismissCommand = toViewModel.DismissCommand;

            if (toViewController is LoginViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is MainViewController)
            {
                var nav = ((UINavigationController)UIApplication.SharedApplication.Delegate.GetWindow().RootViewController);
                UIView.Transition(nav.View, 0.6f,
                    UIViewAnimationOptions.BeginFromCurrentState | UIViewAnimationOptions.TransitionCrossDissolve,
                    () => nav.PushViewController(toViewController, false), null);
            }
            else if (toViewController is AddInterestViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Cancel, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is StumbleViewController || toViewController is RepositoryViewController ||
                     toViewController is StumbledRepositoryViewController || toViewController is SettingsViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(new UINavigationController(toViewController), true, null);
            }
            else if (toViewController is LanguagesViewController && fromViewController is TrendingViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                var ctrlToPresent = new UINavigationController(toViewController);
                ctrlToPresent.TransitioningDelegate = new SlideDownTransition();
                fromViewController.PresentViewController(ctrlToPresent, true, null);
            }
            else if (toViewController is PurchaseProViewController)
            {
                toViewDismissCommand.Subscribe(_ => fromViewController.DismissViewController(true, null));
                toViewController.NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Done, (s, e) => toViewDismissCommand.ExecuteIfCan());
                fromViewController.PresentViewController(toViewController, true, null);
            }
            else
            {
                toViewDismissCommand.Subscribe(
                    _ => toViewController.NavigationController.PopToViewController(fromViewController, true));
                fromViewController.NavigationController.PushViewController(toViewController, true);
            }
        }
开发者ID:memopower,项目名称:RepoStumble,代码行数:51,代码来源:TransitionOrchestrationService.cs

示例3: TakePicture

 public static void TakePicture(UIViewController parent, Action<NSDictionary> callback)
 {
     Init();
     picker.SourceType = UIImagePickerControllerSourceType.Camera;
     _callback = callback;
     parent.PresentViewController((UIViewController)picker, true, (Action)null);
 }
开发者ID:mehul19851,项目名称:xamarin-forms-camera,代码行数:7,代码来源:Camera.cs

示例4: SelectPicture

		public static void SelectPicture (UIViewController parent, Action<NSDictionary> callback)
		{
			Init ();
			picker.SourceType = UIImagePickerControllerSourceType.PhotoLibrary;
			_callback = callback;
			parent.PresentViewController (picker, true, null);
		}
开发者ID:saedaes,项目名称:ProductFinder,代码行数:7,代码来源:Camera.cs

示例5: PresentOKCancelAlert

		/// <summary>
		/// Presents an alert with an OK and a Cancel button.
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's Description.</param>
		/// <param name="controller">The Vinew Controller that will present the alert.</param>
		/// <param name="action">The <c>AlertOKCancelDelegate</c> use to respond to the user's action.</param>
		public static UIAlertController PresentOKCancelAlert(string title, string description, UIViewController controller, AlertOKCancelDelegate action) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

			// Add cancel button
			alert.AddAction(UIAlertAction.Create("Cancel",UIAlertActionStyle.Cancel,(actionCancel) => {
				// Any action?
				if (action!=null) {
					action(false);
				}
			}));

			// Add ok button
			alert.AddAction(UIAlertAction.Create("OK",UIAlertActionStyle.Default,(actionOK) => {
				// Any action?
				if (action!=null) {
					action(true);
				}
			}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:34,代码来源:AlertViewController.cs

示例6: ShowCropViewAsync

        /// <summary>
        /// Shows the crop view and wait for the user's input.
        /// </summary>
        /// <returns>Returns a byte array of the cropped photo or throws an OperationCancelledException if the user cancelled.</returns>
        /// <param name="rootViewController">Root view controller.</param>
        /// <param name="isAnimated">If set to <c>true</c> is animated.</param>
        /// <param name="completionHandler">Completion handler.</param>
        /// <exception cref="System.OperationCanceledException">Thrown when the user hits cancel</exception>
        public Task<byte[]> ShowCropViewAsync(UIViewController rootViewController, bool isAnimated, Action completionHandler)
        {
            var cropViewDelegate = new CropViewControllerDelegate();
            this.Delegate = cropViewDelegate;
            rootViewController.PresentViewController(this, isAnimated, completionHandler);

            return cropViewDelegate.GetResult();
        }
开发者ID:apcurium,项目名称:xamarin-bindings,代码行数:16,代码来源:TOCropViewController.cs

示例7: Alert

		public static void Alert (UIViewController controller, string title, string message)
		{
			UIAlertAction action = UIAlertAction.Create("OK", UIAlertActionStyle.Cancel, null);
			UIAlertController alert = UIAlertController.Create(title, message, UIAlertControllerStyle.Alert);

			alert.Title = title;
			alert.Message = message;

			alert.AddAction(action);
			controller.PresentViewController(alert, true, null);
		}
开发者ID:EckyZero,项目名称:Hashtagg,代码行数:11,代码来源:Device.cs

示例8: TakePicture

        public static void TakePicture(UIViewController parent, Action<NSDictionary> callback)
        {
            Init ();
            picker.SourceType = UIImagePickerControllerSourceType.Camera;
            _callback = callback;

            if (AppDelegate.UserInterfaceIdiomIsPhone == false) {
                popover = new UIPopoverController (picker);
                popover.PresentFromRect (new RectangleF (150, 150, 500, 500), parent.View, UIPopoverArrowDirection.Any, true);
            } else {
                parent.PresentViewController (picker, true, null);
            }
        }
开发者ID:valryon,项目名称:pixpuzzle,代码行数:13,代码来源:Camera.cs

示例9: Show

 public static GistCreateView Show(UIViewController parent)
 {
     var ctrl = new GistCreateView();
     var weakVm = new WeakReference<GistCreateViewModel>(ctrl.ViewModel);
     ctrl.ViewModel.SaveCommand.Subscribe(_ => parent.DismissViewController(true, null));
     ctrl.NavigationItem.LeftBarButtonItem = new UIBarButtonItem { Image = Images.Buttons.CancelButton };
     ctrl.NavigationItem.LeftBarButtonItem.GetClickedObservable().Subscribe(_ => {
         weakVm.Get()?.CancelCommand.Execute(null);
         parent.DismissViewController(true, null);
     });
     parent.PresentViewController(new ThemedNavigationController(ctrl), true, null);
     return ctrl;
 }
开发者ID:GitWatcher,项目名称:CodeHub,代码行数:13,代码来源:GistCreateView.cs

示例10: PresentOKAlert

		/// <summary>
		/// Presents an alert containing only the OK button.
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's description.</param>
		/// <param name="controller">The View Controller that will present the alert.</param>
		public static UIAlertController PresentOKAlert(string title, string description, UIViewController controller) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);

			// Configure the alert
			alert.AddAction(UIAlertAction.Create("OK",UIAlertActionStyle.Default,(action) => {}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:20,代码来源:AlertViewController.cs

示例11: MessageForUser

        public MessageForUser(
            UIViewController viewController,
            string messageText,
            string messageTitle,
            QuestionOptions questionType = QuestionOptions.OK,
            Action postiveAction = null,
            Action negativeAction = null
              )
        {
            if (negativeAction == null)
            {
                negativeAction = () => { };
            }

            if (postiveAction == null)
            {
                postiveAction = () => { };
            }
            var okCancelAlertController = UIAlertController.Create(messageTitle, messageText, UIAlertControllerStyle.Alert);

            switch (questionType)
            {
                case QuestionOptions.OK:
                    okCancelAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, alert => postiveAction()));
                    break;
                case QuestionOptions.OkCancel:
                    okCancelAlertController.AddAction(UIAlertAction.Create("OK", UIAlertActionStyle.Default, alert => postiveAction()));
                    okCancelAlertController.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel, alert => negativeAction()));

                    break;
                case QuestionOptions.YesNo:
                    okCancelAlertController.AddAction(UIAlertAction.Create("Yes", UIAlertActionStyle.Default, alert => postiveAction()));
                    okCancelAlertController.AddAction(UIAlertAction.Create("No", UIAlertActionStyle.Destructive, alert => negativeAction()));

                    break;
                default:
                    break;
            }

            //Present Alert
            viewController.PresentViewController(okCancelAlertController, true, null);
        }
开发者ID:SergeiZag,项目名称:ContosoMobileAppMSA,代码行数:42,代码来源:MessageForUser.cs

示例12: Share

        private static void Share(UIViewController presentingViewController, string toShare)
        {
            var item = new NSString (toShare);
            var activityItems = new NSObject[] { item };
            var activityViewController = new UIActivityViewController (activityItems, null);
            var excludedActivityTypes = new [] {
                UIActivityType.CopyToPasteboard,
                UIActivityType.Mail,
                UIActivityType.PostToWeibo
            };

            if (!MFMessageComposeViewController.CanSendText) {
                excludedActivityTypes = new [] {
                    UIActivityType.CopyToPasteboard,
                    UIActivityType.Mail,
                    UIActivityType.Message,
                    UIActivityType.PostToWeibo
                };
            }

            activityViewController.ExcludedActivityTypes = excludedActivityTypes;
            presentingViewController.PresentViewController (activityViewController, true, null);
        }
开发者ID:pierceboggan,项目名称:Verses,代码行数:23,代码来源:Sharing.cs

示例13: MenuTapped

        private void MenuTapped(UIViewController vc)
        {
            var menuAlertController = UIAlertController.Create("", Strings.LoginAs + " " + UserData.CPRNR, UIAlertControllerStyle.ActionSheet);

            // When user confirms the service
            var logAfAction = UIAlertAction.Create(Strings.LogOff, UIAlertActionStyle.Destructive, action =>
            {
                // Take the user back to Login
                var tabbar = vc.TabBarController;
                var loginController = (LoginViewController)tabbar.ViewControllers[2];
                UserData.IsUserLoggedIn = false;
                tabbar.SelectedViewController = loginController;

            });

            // When user cancels the service
            var cancelAction = UIAlertAction.Create(Strings.Cancel, UIAlertActionStyle.Cancel, action =>
            {
                // Do nothing.

            });

            menuAlertController.AddAction(logAfAction);
            menuAlertController.AddAction(cancelAction);

            var popover = menuAlertController.PopoverPresentationController;

            if (popover != null)
            {
                popover.SourceView = vc.View;
                popover.SourceRect = new CGRect(vc.View.Bounds.Size.Width / 2.0, vc.View.Bounds.Size.Height / 2.0, 1.0, 1.0);
            }

            // Display the alert
            vc.PresentViewController(menuAlertController, true, null);
        }
开发者ID:dsb92,项目名称:patientcare,代码行数:36,代码来源:MenuBarButtonItem.cs

示例14: PresentTextInputAlert

		/// <summary>
		/// Presents an alert that allows the user to input a single line of text.
		/// </summary>
		/// <returns>The <c>UIAlertController</c> for the alert.</returns>
		/// <param name="title">The alert's title.</param>
		/// <param name="description">The alert's description.</param>
		/// <param name="placeholder">The placholder text that will be displayed when the text field is empty.</param>
		/// <param name="text">The initial value for the text field.</param>
		/// <param name="controller">The View Controller that will present the alert.</param>
		/// <param name="action">The <c>AlertTextInputDelegate</c> that will respond to the user's action.</param>
		public static UIAlertController PresentTextInputAlert(string title, string description, string placeholder, string text, UIViewController controller, AlertTextInputDelegate action) {
			// No, inform the user that they must create a home first
			UIAlertController alert = UIAlertController.Create(title, description, UIAlertControllerStyle.Alert);
			UITextField field = null;

			// Add and configure text field
			alert.AddTextField ((textField) => {
				// Save the field
				field = textField;

				// Initialize field
				field.Placeholder = placeholder;
				field.Text = text;
				field.AutocorrectionType = UITextAutocorrectionType.No;
				field.KeyboardType = UIKeyboardType.Default;
				field.ReturnKeyType = UIReturnKeyType.Done;
				field.ClearButtonMode = UITextFieldViewMode.WhileEditing;

			});

			// Add cancel button
			alert.AddAction(UIAlertAction.Create("Cancel",UIAlertActionStyle.Cancel,(actionCancel) => {
				// Any action?
				if (action!=null) {
					action(false,"");
				}
			}));

			// Add ok button
			alert.AddAction(UIAlertAction.Create("OK",UIAlertActionStyle.Default,(actionOK) => {
				// Any action?
				if (action!=null && field !=null) {
					action(true, field.Text);
				}
			}));

			// Display the alert
			controller.PresentViewController(alert,true,null);

			// Return created controller
			return alert;
		}
开发者ID:CBrauer,项目名称:monotouch-samples,代码行数:52,代码来源:AlertViewController.cs

示例15: ShowSearchSearchView

		/// <summary>
		/// Отображение SearchViewController с таблицей
		/// </summary>
		/// <param name="context">Context.</param>
		/// <param name="senderVc">Sender vc.</param>
		/// <param name="searchStations">Search stations.</param>
		void ShowSearchSearchView (string context, UIViewController senderVc, IList<SectionStation> searchStations){
			var tableTest = new CitiesScheduleView (showAll,context,searchStations);
			tableTest.TableView.KeyboardDismissMode = UIScrollViewKeyboardDismissMode.OnDrag;
			var searchController = new UISearchController (tableTest);
			searchController.DimsBackgroundDuringPresentation = true;
			searchController.ObscuresBackgroundDuringPresentation = true;
			searchController.DefinesPresentationContext = false;
			senderVc.DefinesPresentationContext = true;
			searchController.SearchResultsUpdater = tableTest;
			senderVc.PresentViewController (searchController, true, null);
		}
开发者ID:kvandake,项目名称:TytySample,代码行数:17,代码来源:ScheduleViewModel.cs


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