Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 以编程方式创建UITableViewController时使用情节提要_Ios_Objective C_Uitableview_Ios7 - Fatal编程技术网

Ios 以编程方式创建UITableViewController时使用情节提要

Ios 以编程方式创建UITableViewController时使用情节提要,ios,objective-c,uitableview,ios7,Ios,Objective C,Uitableview,Ios7,我想使用我在序列图像板中创建的表视图以编程方式创建UITableViewController,其中我将序列图像板命名为TableViewCont.storyboard 下面是我试图在AppDelegate.m中使用的代码: - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions { NSBundle *bundle = [NSBu

我想使用我在序列图像板中创建的表视图以编程方式创建UITableViewController,其中我将序列图像板命名为
TableViewCont.storyboard

下面是我试图在
AppDelegate.m
中使用的代码:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   NSBundle *bundle = [NSBundle mainBundle];
   UITableViewController *tvc = [[UITableViewController alloc] initWithNib:@"TableViewCont" bundle:bundle];
   self.window.rootViewController = tvc;
   return YES;
}

没有报告语法错误,但当我在设备上运行应用程序时,TableViewController不会显示。当您使用
initWithNib:bundle:
初始化时,我知道
UITableViewController
的功能不同于
UIViewController
,但我不明白为什么此代码不起作用…

您不能在故事板中使用initWithNib。这是针对xib文件的

要从情节提要中初始化控制器,必须使用实例化eviewcontrollerwhiteIdentifier。请参见下面的示例

UIStoryboard *storyboard = [UIStoryboard storyboardWithName:@"TableViewCont" bundle:nil]; 

UITableViewController *tvc = (UITableViewController *)[storyboard instantiateViewControllerWithIdentifier:@"your identifier"];
别忘了在情节提要中输入tableview控制器的标识符