顯示界面的切換/控制器的跳轉

 

 

(本身使用過的介紹)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]; }

相關文章
相關標籤/搜索