故事板问题

时间:2013-10-07 09:20:36

标签: ios xcode mobile storyboard

我想在我的旧项目(使用xibs实现)中使用storyboard来添加新功能。

我创建了storyboard文件并为其添加了一个视图控制器,在Identity检查器中我已经为视图控制器指定了类名。

@implementation AppDelegate


- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // Override point for customization after application launch.

    UINavigationController *navController = [[UINavigationController alloc] initWithRootViewController:[[FirstViewController alloc]initWithNibName:@"FirstViewController" bundle:[NSBundle mainBundle]]];
    self.window.rootViewController = navController;
    [self.window makeKeyAndVisible];
    return YES
}


@end

在firstviewcontroller中,当我点击一个按钮时,它会调用gotoSomeviewController方法,在那里它将从EventsScreen故事板加载到eventslistViewController加载

@implementation FirstViewController

-(void)gotoSomeviewController
{
    EventsListViewController *vc = [[UIStoryboard storyboardWithName:@"EventsScreen" bundle:nil] instantiateInitialViewController];

[controller pushViewController:vc animated:YES];     }

@end

当我正在运行应用程序时,EventsListViewController显示一个空白屏幕,但没有我在故事板中添加的视图。

1 个答案:

答案 0 :(得分:1)

根据提供的信息,您没有理由混合使用NIB和Storyboard。

我会设置一个故事板。删除app委托代码并设置项目以加载特定设备的故事板。

设置故事板以使初始视图控制器为UINavigationController,其中FirstViewController为其根。

然后您只需从按钮拖动到SecondViewController,然后选择推送作为移动选项。然后删除gotoviewcontroller的方法。没有理由你有这样的设置...

相关问题