iOS 多控制器之间的跳转
2016-05-14 本文已影响316人
ivin
1.代码方式跳转
/** 取出 storyboard 中 ID 为"edit"的控制器*/
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"Main" bundle:nil];
XBEditViewController *vc = [storyboard instantiateViewControllerWithIdentifier:@"edit"];
/** 向控制器传递数据 */
vc.contact = self.contacts[indexPath.row];
vc.block = ^{
[self.tableView reloadData];
};
/** 压栈跳转控制器 */
[self.navigationController pushViewController:vc animated:YES];
2. storyboard连线跳转方式,根据绑定的 ID 进行控制器跳转
[ self performSegueWithIdentifier:@"jumpToContact" sender:nil ];
然后系统会调用
- (void)prepareForSegue:(UIStoryboardSegue*)segue sender:(id)sender
3. 模态弹出的
- (void)presentViewController:(UIViewController*)viewControllerToPresent animated: (BOOL)flag completion:(void(^)(void))completion
- (void)dismissViewControllerAnimated: (BOOL)flag completion: (void(^)(void))completion;