宽容他人,放过自己。

页面push直接推storyBord

Posted on By anchoriteFili

创建一个新的storybord,让页面与storybord进行连接,直接推出storybord。

1. 创建一个独立的storybord

752372-20151209110113933-2147071965.png

2. 页面进行连接

752372-20160510135236452-1131486059.png

3. 用代码直接进行推
#pragma mark 类扩展进行页面的扩展
UIViewController *pushStoryboard(NSString *storyboardName,NSString *identifier) {
    
    UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:storyboardName bundle:nil];
    UIViewController *viewController = [storyBoard instantiateViewControllerWithIdentifier:identifier]; //test2为viewcontroller2的StoryboardId
    return viewController;
}

/**
     如果index = 0,则利用类扩展方法进行推页面
     否则不用类扩展推页面
     */
    
    int index = 1;
    
    if (index == 0) {
        [self.navigationController pushViewController: pushStoryboard(@"Storyboard", @"test2") animated:YES];
    } else {
        UIStoryboard *storyBoard = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];
        UIViewController *viewController = [storyBoard instantiateViewControllerWithIdentifier:@"test2"]; //test2为viewcontroller2的StoryboardId
        
        [self.navigationController pushViewController:viewController animated:YES];
    }