@SanMao
2015-08-06T00:32:21.000000Z
字数 2070
阅读 1904
知识补充
- (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.
/*
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);
自动型:点击某个控件(比如按钮)的时候自动跳转到下一个控制器(按住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是modal
Storyboard上每一根用来界面跳转的线,都是一个UIStoryboardSegue对象(简称Segue)