显示界面的切换/控制器的跳转

 

 

(本身使用过的介绍)post

2016/1/22                    0:26url

关闭当前控制器

[self.navigationController popViewControllerAnimated:YES];spa

-----------------------------------------------------------------------------------对象

回到根控制器   

[self.navigationController popToRootViewControllerAnimated:YES];ip

-----------------------------------------------------------------------------------it

 

push控制器

UIViewController *vc= [[UIViewController alloc]init];
            
[self.navigationController pushViewController:vc animated:YES];
io

-----------------------------------------------------------------------------------ast

show控制器

UIViewController *vc = [[UIViewController alloc]init];
            
vc.view.backgroundColor = [UIColor yellowColor];
            
[self.navigationController showViewController:vc sender:nil];
object

 

UIViewController *vc = [[UIViewController alloc]init];
            
vc.view.backgroundColor = [UIColor yellowColor];
            
[self.navigationController showDetailViewController:vc sender:nil];
model

-----------------------------------------------------------------------------------

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 = [UIStoryboard

storyboardWithName:@"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]; }

相关文章
相关标签/搜索