iOS - “UIViewController from storyboard “Main",但没有得到 UITableView [英] iOS - "UIViewController from storyboard "Main", but didn't get a UITableView

查看:19
本文介绍了iOS - “UIViewController from storyboard “Main",但没有得到 UITableView的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 UIViewController,里面有 UITableView.一切正常.在didSelectRowAtIndexPath"方法中,我想激活到 UIViewController 的显示"segue.我将它设置在 Storyboard 中,创建了它的 ViewController 类等.

I have an UIViewController which has UITableView in it. Everything works fine. In "didSelectRowAtIndexPath" methos I want to activate a "show" segue to UIViewController. I set it in Storyboard, created its ViewController class etc.

当我选择单元格时,我收到一条错误消息:

When I choose the cell, I get an error saying:

*** 由于未捕获的异常NSInternalInconsistencyException"而终止应用程序,原因:-[UITableViewController"loadView] 带有标识符的实例化视图控制器故事板Main"中的UIViewController-ndM-tm-7SM",但没有得到UITableView.'

*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UITableViewController loadView] instantiated view controller with identifier "UIViewController-ndM-tm-7SM" from storyboard "Main", but didn't get a UITableView.'

有趣的是,我发现虽然我将一个 ViewController 放到 storyboard 中,但它本身正在变成 Table View Controller.这是图:

Interestingly, I found that although I put a ViewController to the storyboard, it's changing to Table View Controller by itself. It's picture:

这不是初始情况,起初我检查了同一个地方,只有 ViewController.大概这就是问题所在.

Tis is not initial situation, at first i checked the same place and there were only ViewController. Probably this is the problem.

我看了之前问过的同样的问题,但它们是不同的.我的根视图控制器不是表视图控制器,它是包含表视图的视图控制器.

I looked the same question asked before but they are different. My root view controller is not table view controller, it's view controller including table view.

无论如何,我该怎么办?我也使用 prepareForSegue 方法,似乎没有任何问题.

Anyway, what should i do to handle this? I use prepareForSegue method either and it seems that there's nothing wrong about it.

谢谢!

推荐答案

你绝对可以创建从一个 VC 到另一个 VC 的 segue,并从 didSelectRowAtIndexpath

You definately can create a segue from a VC to another VC, and call it from didSelectRowAtIndexpath

我尝试创建从 rootViewController(不是单元格)到 detailViewController 的 segue,它工作正常.

I've tried to create a segue from the rootViewController (not the cell) to the detailViewController, it works fine.

首先,确保您已在故事板中连接了数据源和委托.

First, make sure you have connected the dataSource and delegate in storyboard.

然后连接segue,

然后在您的 didSelectRowAtIndexPath 方法中:

Then in your didSelectRowAtIndexPath method:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
    [self performSegueWithIdentifier:@"show" sender:[tableView cellForRowAtIndexPath:indexPath]];
}

这应该有效.

这篇关于iOS - “UIViewController from storyboard “Main",但没有得到 UITableView的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆