Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
230 views
in Technique[技术] by (71.8m points)

objective c - iOS - "UIViewController from storyboard "Main", but didn't get a UITableView

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:

*** 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.'

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

enter image description here

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.

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

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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. enter image description here

Then connect the segue, enter image description here

Then in your didSelectRowAtIndexPath method:

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

And this should be working.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...