根据名称加载界面

根据nib名称可以实现根据配置文件实例化UIViewController,也可以使用instantiateViewControllerWithIdentifier方法从Storyboard实例化UIViewController

 

UIViewController *vc;

//判断nib是否存在,如果存在,就加载
if ([[NSBundle mainBundle] pathForResource:destination ofType:@"nib"] != nil) {
    vc = [[UIViewController alloc] initWithNibName:destination bundle:nil];

else {

    //从Storyboard实例化ViewController
    UIStoryboard *sb = [UIStoryboard storyboardWithName:@"MainStoryboard" bundle:nil];
    vc = [sb instantiateViewControllerWithIdentifier:destination];
}
     
[self.navigationController pushViewController:vc animated:YES];

 

posted @ 2012-05-21 21:22  静候良机  阅读(340)  评论(0)    收藏  举报