(自己使用过的介绍)
2016/1/22 0:26
关闭当前控制器
[self.navigationController popViewControllerAnimated:YES];
-----------------------------------------------------------------------------------
回到根控制器
[self.navigationController popToRootViewControllerAnimated:YES];
-----------------------------------------------------------------------------------
push控制器
UIViewController *vc= [[UIViewController alloc]init];
[self.navigationController pushViewController:vc animated:YES];
-----------------------------------------------------------------------------------
show控制器
UIViewController *vc = [[UIViewController alloc]init];
vc.view.backgroundColor = [UIColor yellowColor];
[self.navigationController showViewController:vc sender:nil];
UIViewController *vc = [[UIViewController alloc]init];
vc.view.backgroundColor = [UIColor yellowColor];
[self.navigationController showDetailViewController:vc sender:nil];
-----------------------------------------------------------------------------------
model控制器
UIViewController *vc = [[UIViewController alloc]init];
// 跳转特效
vc.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
// modal跳转 相当于push show
[self presentViewController:vc animated:YES completion:nil];
Model 效果/*
UIModalTransitionStyleCoverVertical 默认从下往上
UIModalTransitionStyleFlipHorizontal 酷炫翻转
UIModalTransitionStyleCrossDissolve 闪现
UIModalTransitionStylePartialCurl 翻页
*/
-----------------------------------------------------------------------------------
覆盖法:
UIViewController *vc = [[UIViewController alloc]init];
// 获取主窗口
UIWindow *window = [UIApplication sharedApplication].keyWindow;
vc.view.frame = window.bounds;
// 添加view
[self.view.window addSubview:vc.view];
-----------------------------------------------------------------------------------
替换法:
// 更换 根控制器 的界面跳转
UIViewController *vc = [[UIViewController alloc]init];
self.view.window.rootViewController = vc;
-----------------------------------------------------------------------------------
加载 storyboard
UIStoryboard *storyboard = [UIStoryboardstoryboardWithName:@"storyboard文件名" bundle:nil];
// 获取 storyboard 初始控制器UIViewController *vc = [storyboard
instantiateInitialViewController];
然后push,show,model,替换,覆盖,任你选
-----------------------------------------------------------------------------------
加载xib
// 加载xib
<#类#> *<#对象#> = [[[NSBundle mainBundle] loadNibNamed:@"<#Xib名#>" owner:nil options:nil] lastObject];
-----------------------------------------------------------------------------------
xib 跳转控制器
- (void)presentControllerWithStoryboardName:(NSString *)storyboardName {
//要加载控制器必须先获得storyboard对象
UIStoryboard *storyboard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
// 获取 到更控制器
UIViewController *vc = [storyboard instantiateInitialViewController];
//发布通知
[[NSNotificationCenter defaultCenter] postNotificationName:XibPushController
object:vc];
}