Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/ios/113.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/23.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
didSelectRowAtIndexPath中的DetailViewController-iOS iPhone 5目标c_Ios_Objective C - Fatal编程技术网

didSelectRowAtIndexPath中的DetailViewController-iOS iPhone 5目标c

didSelectRowAtIndexPath中的DetailViewController-iOS iPhone 5目标c,ios,objective-c,Ios,Objective C,我想在点击MasterViewController中表格的第一个单元格时加载DetailViewController(num==0)。这是我现在拥有的代码: - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath]; N

我想在点击MasterViewController中表格的第一个单元格时加载DetailViewController(num==0)。这是我现在拥有的代码:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{

    UITableViewCell *cell=[tableView cellForRowAtIndexPath:indexPath];
    NSInteger num = indexPath.row;
    if(num == 0){
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        self.viewController = [[DetailViewController alloc] initWithNibName:@"Detail" bundle:nil];
        self.window.rootViewController = self.viewController;
        [self.window makeKeyAndVisible];
    } else if(num == 1){

    }

}

但这给了我们一个线索1:SIGABRT。如何在情节提要中加载名为Detail的DetailViewController?

不要分配新的UIWindow对象。 正如您所做的那样,只需从nib加载DetailViewController。 然后按下它,假设您当前的视图控制器已经由导航控制器控制

[self.navigationController pushViewController:self.viewController animated:YES];

我们能看到崩溃日志吗?为什么要创建一个新窗口?你有导航控制器吗?我只想在点击表格中的不同单元格时加载不同的DetailViewController。你能给我提供正确的代码吗?这个问题已经被问了很多次了,所以做一些搜索吧。你也可以在苹果的“iOS表视图编程指南”文档中看到如何做到这一点。你有导航控制器吗?赛格?你需要提供细节