Push和Modal的区别
来源:互联网 发布:rekordbox软件的作用 编辑:程序博客网 时间:2024/05/21 02:52
Push和Modal的区别
标签(空格分隔): 知识补充
- 切换控制器的两种方法:push,modal
Push(代码方式,storyboa方式)
- (void)pushViewController:(UIViewController *)viewController animated:(BOOL)animated; // Uses a horizontal slide transition. Has no effect if the view controller is already in the stack.- (UIViewController *)popViewControllerAnimated:(BOOL)animated; // Returns the popped controller.- (NSArray *)popToViewController:(UIViewController *)viewController animated:(BOOL)animated; // Pops view controllers until the one specified is on top. Returns the popped controllers.- (NSArray *)popToRootViewControllerAnimated:(BOOL)animated; // Pops until there's only a single view controller left on the stack. Returns the popped controllers.
- push方法切换控制器是通过导航控制器来实现,导航控制器的作用相当于是要切换的几个控制器之间的管理者(导航控制器的栈来管理),跳转后,原来的控制器会被移除导航控制器的栈,但是不会立即销毁,移除栈的控制器会被放入自动释放池,等事件循环结束后如果没有强指针指向它,这时就会被销毁。
Modal
/* The next two methods are replacements for presentModalViewController:animated and dismissModalViewControllerAnimated: The completion handler, if provided, will be invoked after the presented controllers viewDidAppear: callback is invoked.*/- (void)presentViewController:(UIViewController *)viewControllerToPresent animated: (BOOL)flag completion:(void (^)(void))completion NS_AVAILABLE_IOS(5_0);// 关闭当初Modal出来的控制器- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void (^)(void))completion NS_AVAILABLE_IOS(5_0);
- modal方法跳转控制器只是把目标控制器的View加到了现有控制器上,添加后的View依旧需要目标来管理,而且源控制也不会随新Modal来得View而移除销毁。Modal一般适用于两个不相关的控制器切换(Modal的效果是从屏幕底部向上覆盖源控制器的View)
storyboard中通过segue跳转
自动型:点击某个控件(比如按钮)的时候自动跳转到下一个控制器(按住Control键,直接从控件拖线到目标控制器,适用于不需要做任何判断的跳转)
手动型:需要通过写代码手动执行Segue(必须由来源控制器执行Segue),才能完成界面跳转(按住Control键,从来源控制器拖线到目标控制器,适用于需要做一些判断后再跳转的情况,比如登录的时候判断账号密码)
// 跳转前做的一些准备工作- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender NS_AVAILABLE_IOS(5_0);// 用来源控制器手动执行此方法- (void)performSegueWithIdentifier:(NSString *)identifier sender:(id)sender NS_AVAILABLE_IOS(5_0);
- 如果segue的style是push
- 取得sourceViewController所在的UINavigationController
- 调用UINavigationController的push方法将destinationViewController压入栈中,完成跳转
如果segue的style是modal
- 调用sourceViewController的presentViewController方法将destinationViewController展示出来
Storyboard上每一根用来界面跳转的线,都是一个UIStoryboardSegue对象(简称Segue)
0 0
- Push和Modal的区别
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载) (
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载)
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载)
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载)
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载)
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom(转载)
- Storyboard里面的几种Segue区别:push,modal,popover,replace和custom
- push,present,modal(模态)新界面的区别
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- Storyboard里面的几种Segue区别及视图的切换:push,modal,popover,replace和custom
- linux tar 各种参数详解, zip , rar
- BusyBox
- 系统方法调用总结
- 使用未公开关键字在 C# 中导入外部 printf 等参数数量可变函数 [1] CLR 支持
- 24-IO流-55-IO流(ObjectOutputStream-对象的序列化)
- Push和Modal的区别
- NVMe的目标:释放闪存潜能
- pageX,clientX,screenX,offsetX区别
- 白话设计模式之--策略模式
- 黑马程序员————集合类
- 定时器的使用
- java统计字符串中各个字符的出现次数
- hdoj-1242-Rescue【广搜+优先队列】
- 24-IO流-56-IO流(ObjectInputStream-对象的反序列化)