public virtual void TransitionPanel(UIViewController newChildView) { Transition(PanelView, newChildView, 1.0, UIViewAnimationOptions.CurveEaseOut, () => { }, (finished) => { PanelView.RemoveFromParentViewController(); newChildView.DidMoveToParentViewController(this); PanelView = newChildView; }); }
public YYCommentContainerViewController (UIViewController child) : base () { contentController = child; AddChildViewController (child); child.DidMoveToParentViewController (this); if (child.WantsFullScreenLayout) { WantsFullScreenLayout = true; UIApplication.SharedApplication.SetStatusBarStyle (UIStatusBarStyle.BlackTranslucent, false); } commentViewController = new YYCommentViewController (); commentViewController.associatedObject = (PhotoViewController)child; }
// - (void)setContentViewController:(UIViewController *)contentViewController public void SetContentViewController (UIViewController controller) { if (contentViewController != controller) { if (contentViewController != null) { contentViewController.WillMoveToParentViewController(null); contentViewController.RemoveFromParentViewController(); contentViewController.Dispose(); } contentViewController = controller; AddChildViewController(contentViewController); contentViewController.DidMoveToParentViewController(this); } }
// - (void)setMenuViewController:(UIViewController *)menuViewController public void SetMenuViewController (UIViewController controller) { if (menuViewController != controller) { if (menuViewController != null) { menuViewController.WillMoveToParentViewController (null); menuViewController.RemoveFromParentViewController (); menuViewController.Dispose (); } menuViewController = controller; AddChildViewController (menuViewController); menuViewController.DidMoveToParentViewController (this); } }
// - (void)setleftMenuViewController:(UIViewController *)leftMenuViewController public void SetLeftMenuViewController(UIViewController controller) { if (leftMenuViewController != controller) { if (leftMenuViewController != null) { leftMenuViewController.WillMoveToParentViewController(null); leftMenuViewController.RemoveFromParentViewController(); leftMenuViewController.Dispose(); } leftMenuViewController = controller; AddChildViewController(leftMenuViewController); leftMenuViewController.DidMoveToParentViewController(this); } }
protected override void OnElementChanged (VisualElementChangedEventArgs e) { base.OnElementChanged (e); var page = e.NewElement as MyThirdPage; var hostViewController = ViewController; var viewController = new UIViewController (); var label = new UILabel (new CGRect(0, 40, 320, 40)); label.Text = "3 " + page.Heading; viewController.View.Add (label); hostViewController.AddChildViewController (viewController); hostViewController.View.Add (viewController.View); viewController.DidMoveToParentViewController (hostViewController); }
protected override void OnModelSet(Xamarin.Forms.VisualElement model) { base.OnModelSet (model); var page = model as MyThirdPage; var hostViewController = ViewController; var viewController = new UIViewController (); var label = new UILabel (new RectangleF(0, 40, 320, 40)); label.Text = "3 " + page.Heading; viewController.View.Add (label); hostViewController.AddChildViewController (viewController); hostViewController.View.Add (viewController.View); viewController.DidMoveToParentViewController (hostViewController); }
private void CycleFromViewControllerToViewController(UIViewController oldController, UIViewController newController) { if (!MidTransition) { MidTransition = true; oldController.WillMoveToParentViewController(null); this.AddChildViewController(newController); // Whether this is a good UI choice aside, Scroll next UIViewController in from Right (alter as required for other transitions) RectangleF newControllerStartFrame = new RectangleF(ContainerView.Frame.Location.X + ContainerView.Frame.Size.Width, ContainerView.Frame.Location.Y, ContainerView.Frame.Size.Width, ContainerView.Frame.Size.Height); RectangleF oldControllerEndFrame = new RectangleF(ContainerView.Frame.Location.X - ContainerView.Frame.Size.Width, ContainerView.Frame.Location.Y, ContainerView.Frame.Size.Width, ContainerView.Frame.Size.Height); newController.View.Frame = newControllerStartFrame; // If you try to start another Container change whilst previous one is in the middle of an animation, you will get an error, such as - // Unbalanced calls to begin/end appearance transitions for <NibViewController: 0xd503cc0>. // Unbalanced calls to begin/end appearance transitions for <ProgrammaticViewController: 0x14d58c30 .. // Tried disabling UISegementedControl click to stop this happening but was jarring, so went for MidTransition variable. // ChooseVCUISegementedControl.Enabled = false; Transition(oldController, newController, 0.25, /*UIViewAnimationOptions.TransitionFlipFromLeft*/ 0, () => { newController.View.Frame = oldController.View.Frame; oldController.View.Frame = oldControllerEndFrame; }, delegate(bool finished) { oldController.RemoveFromParentViewController(); newController.DidMoveToParentViewController(this); //ChooseVCUISegementedControl.Enabled = true; MidTransition = false; }); } }
void SetContentViewController (UIViewController cvc) { if (_contentViewController == null) { cvc.View.Frame = _contentView.Bounds; _contentViewController = cvc; AddChildViewController (_contentViewController); _contentView.AddSubview (_contentViewController.View); _contentViewController.DidMoveToParentViewController (this); } else if (_contentViewController != cvc) { cvc.View.Frame = _contentView.Bounds; _contentViewController.WillMoveToParentViewController (null); AddChildViewController (cvc); View.UserInteractionEnabled = false; Transition (_contentViewController, cvc, 0, UIViewAnimationOptions.TransitionNone, () => {}, (finished) => { View.UserInteractionEnabled = true; _contentViewController.RemoveFromParentViewController (); cvc.DidMoveToParentViewController (this); _contentViewController = cvc; }); } }
public virtual void Present(UIViewController controller, bool animated) { this.IsNavigating = true; this.AddChildViewController(controller); this.presentedController = controller; presentedController.View.Alpha = 0; presentedController.View.Frame = new RectangleF(this.ContentView.Bounds.Width, 0, this.ContentView.Bounds.Width, this.ContentView.Bounds.Height); if (this.ShadowEnabled) { // ? maybe this.ApplyShadow(presentedController.View); } this.View.InsertSubviewAbove(controller.View, this.ContentView); if (animated) { UIView.Animate(0.3f, 0, UIViewAnimationOptions.CurveEaseInOut | UIViewAnimationOptions.BeginFromCurrentState, () => { this.ContentView.Frame = new RectangleF(0 - this.contentWidth + this.currentScrolledOffset, 0, this.ContentView.Bounds.Width, this.ContentView.Bounds.Height); this.TitleView.Alpha = 0f; presentedController.View.Alpha = 1f; presentedController.View.Frame = this.View.Bounds; }, () => { presentedController.DidMoveToParentViewController(this); this.IsNavigating = false; }); } else { this.ContentView.Frame = new RectangleF(0 - this.contentWidth + this.currentScrolledOffset, 0, this.ContentView.Bounds.Width, this.ContentView.Bounds.Height); this.TitleView.Alpha = 0f; presentedController.View.Alpha = 1f; presentedController.View.Frame = this.View.Bounds; presentedController.DidMoveToParentViewController(this); this.IsNavigating = false; } }
public void AddController(UIViewController controller, float width) { this.AddChildViewController(controller); this.items.Add(new PanoramaItem(controller, width)); if (this.hasAppeared) { this.CalculateItemMetrics(this.contentTop); this.LayoutContent(this.currentScrolledOffset); } controller.DidMoveToParentViewController(this); }
void SetRightMenuViewController(UIViewController rightMenuViewController) { if (_rightMenuViewController == null) { _rightMenuViewController = rightMenuViewController; return; } HideViewController(_rightMenuViewController); _rightMenuViewController = rightMenuViewController; AddChildViewController(_rightMenuViewController); _rightMenuViewController.View.Frame = View.Bounds; _rightMenuViewController.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; _menuViewContainer.AddSubview(_rightMenuViewController.View); _rightMenuViewController.DidMoveToParentViewController(this); AddMenuViewControllerMotionEffects (); View.BringSubviewToFront(_contentViewContainer); }
void SetContentViewController(UIViewController contentViewController) { if (_contentViewController == null) { _contentViewController = contentViewController; return; } HideViewController(_contentViewController); _contentViewController = contentViewController; AddChildViewController(_contentViewController); _contentViewController.View.Frame = View.Bounds; _contentViewContainer.AddSubview (_contentViewController.View); _contentViewController.DidMoveToParentViewController (this); UpdateContentViewShadow (); if (Visible) { AddContentViewControllerMotionEffects (); } }
public void SetRightMenuViewController(UIViewController controller) { if (rightMenuViewController != controller) { if (rightMenuViewController != null) { rightMenuViewController.WillMoveToParentViewController (null); rightMenuViewController.RemoveFromParentViewController (); rightMenuViewController.Dispose (); } rightMenuViewController = controller; if (controller != null) { AddChildViewController (rightMenuViewController); rightMenuViewController.DidMoveToParentViewController (this); } } }
private void ApplySideController(ref UIViewController controllerStore, UIViewController newController, UIViewController otherController, Action clearOtherController) { Action<UIViewController> beforeBlock = (x) => {}; Action<UIViewController, bool> afterBlock = (x, y) => {}; if (this.viewAppeared) { beforeBlock = (controller) => { controller.View.RemoveFromSuperview(); }; afterBlock = (controller, left) => { controller.View.Hidden = left ? this.SlidingControllerView.Frame.Location.X <= 0 : this.SlidingControllerView.Frame.Location.X >= 0; controller.View.Frame = this.ReferenceBounds; controller.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; if (this.slidingController != null) { this.referenceView.InsertSubviewBelow(controller.View, this.SlidingControllerView); } else { this.referenceView.AddSubview(controller.View); } }; } // start the transition if (controllerStore != null) { controllerStore.WillMoveToParentViewController(null); if (newController == this.CenterController) { this.CenterController = null; } if (newController == otherController && clearOtherController != null) clearOtherController(); beforeBlock(controllerStore); // controllerStore.setViewDeckController(null); controllerStore.RemoveFromParentViewController(); controllerStore.DidMoveToParentViewController(null); } // make the switch if (controllerStore != newController) { // todo: dispose II_RELEASE(*controllerStore); controllerStore = newController; } if (controllerStore != null) { newController.WillMoveToParentViewController(null); newController.RemoveFromParentViewController(); newController.DidMoveToParentViewController(null); // and finish the transition UIViewController parentController = (this.referenceView == this.View) ? this : this.GetGrandParent(); if (parentController != null) { parentController.AddChildViewController(controllerStore); } // controllerStore.setViewDeckController(this); afterBlock(controllerStore, controllerStore == this.LeftController); controllerStore.DidMoveToParentViewController(parentController); } }
public void Present(UIViewController controller) { this.AddChildViewController(controller); this.presentedController = controller; presentedController.View.Alpha = 0; presentedController.View.Frame = this.View.Bounds; this.View.InsertSubviewBelow(controller.View, this.ContentView); var scale1 = MonoTouch.CoreGraphics.CGAffineTransform.MakeScale(0.9f, 0.9f); var translate1 = MonoTouch.CoreGraphics.CGAffineTransform.MakeTranslation(30, this.headerHeight); presentedController.View.Transform = MonoTouch.CoreGraphics.CGAffineTransform.Multiply(scale1, translate1); UIView.Animate(0.3f, 0, UIViewAnimationOptions.CurveEaseIn | UIViewAnimationOptions.BeginFromCurrentState, () => { var scale = MonoTouch.CoreGraphics.CGAffineTransform.MakeScale(1.1f, 1.1f); var translate = MonoTouch.CoreGraphics.CGAffineTransform.MakeTranslation(-100, -this.headerHeight); this.ContentView.Transform = MonoTouch.CoreGraphics.CGAffineTransform.Multiply(scale, translate); this.ContentView.Alpha = 0; this.TitleView.Alpha = 0.3f; //presentedController.View.Alpha = 1f; //presentedController.View.Transform = MonoTouch.CoreGraphics.CGAffineTransform.MakeIdentity(); }, () => { UIView.Animate(0.3f, 0, UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.BeginFromCurrentState, () => { //var scale = MonoTouch.CoreGraphics.CGAffineTransform.MakeScale(1.1f, 1.1f); //var translate = MonoTouch.CoreGraphics.CGAffineTransform.MakeTranslation(-100, -70); //this.ContentView.Transform = MonoTouch.CoreGraphics.CGAffineTransform.Multiply(scale, translate); //this.ContentView.Alpha = 0; this.TitleView.Alpha = 0; presentedController.View.Alpha = 1f; presentedController.View.Transform = MonoTouch.CoreGraphics.CGAffineTransform.MakeIdentity(); }, () => { presentedController.DidMoveToParentViewController(this); }); }); }
public void AddViewController(UIViewController viewController, MobileDialogPresentationType presentationType) { var itemExists = _viewControllers.FirstOrDefault(x => x.Item1 == viewController); if (itemExists != null) { UIView.Animate(0.2, () => itemExists.Item1.View.Alpha = 1); return; } _viewControllers.Add(new Tuple<UIViewController, MobileDialogPresentationType>(viewController, presentationType)); UIView view = viewController.View; view.Alpha = 0; if (presentationType == MobileDialogPresentationType.TabBar) { // This one is a bit different; we are adding it as a child of the TabBar controller //TabBarController.AddChildViewController(viewController); //TabBarController.View.AddSubview(view); View.AddSubview(view); //viewController.View.BringSubviewToFront(view); //viewController.DidMoveToParentViewController(TabBarController); //var appDelegate = (AppDelegate)UIApplication.SharedApplication.Delegate; //appDelegate.root } else { AddChildViewController(viewController); View.AddSubview(view); viewController.View.BringSubviewToFront(view); viewController.DidMoveToParentViewController(this); } switch (presentationType) { case MobileDialogPresentationType.Overlay: view.Frame = new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height); break; case MobileDialogPresentationType.NotificationBar: view.Frame = new RectangleF(0, View.Bounds.Height, View.Bounds.Width, 54); break; case MobileDialogPresentationType.TabBar: //view.Frame = new RectangleF(0, TabBarController.View.Bounds.Height, TabBarController.View.Bounds.Width, 54); float tabBarHeight = 49; view.Frame = new RectangleF(0, TabBarController.View.Bounds.Height - 54 - tabBarHeight, TabBarController.View.Bounds.Width, 54); view.Alpha = 1; break; } int notificationViewCount = _viewControllers.Count(x => x.Item2 == MobileDialogPresentationType.NotificationBar); switch (presentationType) { case MobileDialogPresentationType.Overlay: UIView.Animate(0.2, 0, UIViewAnimationOptions.CurveEaseInOut, () => view.Alpha = 1, null); break; case MobileDialogPresentationType.NotificationBar: UIView.Animate(0.4, 0, UIViewAnimationOptions.CurveEaseInOut, () => { _isAnimating = true; view.Alpha = 1; view.Frame = new RectangleF(0, View.Bounds.Height - (notificationViewCount * 54), View.Bounds.Width, 54); TabBarController.View.Frame = new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height - (notificationViewCount * 54)); }, () => _isAnimating = false); break; case MobileDialogPresentationType.TabBar: float tabBarHeight = 49; view.Alpha = 1; view.Frame = new RectangleF(0, TabBarController.View.Bounds.Height - 54 - tabBarHeight, TabBarController.View.Bounds.Width, 54); // UIView.Animate(0.4, 0, UIViewAnimationOptions.CurveEaseInOut, () => // { // float tabBarHeight = 49; // _isAnimating = true; // view.Alpha = 1; // view.Frame = new RectangleF(0, TabBarController.View.Bounds.Height - 54 - tabBarHeight, TabBarController.View.Bounds.Width, 54); // //TabBarController.View.Frame = new RectangleF(0, 0, View.Bounds.Width, View.Bounds.Height - 54); // }, () => _isAnimating = false); break; } }
private void DisplayContentController(UIViewController content) { AddChildViewController(content); content.View.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight; content.View.Frame = new CGRect(0, 0, View.Frame.Size.Width, View.Frame.Size.Height); View.AddSubview(content.View); content.DidMoveToParentViewController(this); }
private void DisplayContentController(UIViewController content) { this.AddChildViewController(content); content.View.Frame = ContainerView.Frame; this.View.AddSubview(content.View); content.DidMoveToParentViewController(this); }
public void SetContentViewController(UIViewController contentViewController, bool animated) { if (_contentViewController == contentViewController) { return; } if (!animated) { SetContentViewController(contentViewController); } else { AddChildViewController(contentViewController); contentViewController.View.Alpha = 0; contentViewController.View.Frame = _contentViewContainer.Bounds; _contentViewContainer.AddSubview(contentViewController.View); UIView.Animate(_animationDuration, () => { contentViewController.View.Alpha = 1; }, () => { HideViewController(_contentViewController); contentViewController.DidMoveToParentViewController(this); _contentViewController = contentViewController; StatusBarNeedsAppearanceUpdate(); UpdateContentViewShadow(); if (Visible) { AddContentViewControllerMotionEffects(); } }); } }