简体   繁体   中英

Segue from UITableViewCell to another ViewController

I have a created an Single view application with storyboard, I dragged and dropped a TableView . I am able to inflate the tableview and get some data but on clicking any of the UITableViewCell I need to goto the next ViewController . I dragged and dropped another ViewController to the storyboard and connected the MainViewController to the newly created ViewController . I need to goto the new View controller from the didSelectRowAtIndexPath method

I tried using this

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
TestViewController *test = [self.storyboard instantiateViewControllerWithIdentifier:@"Testing"];
[test performSegueWithIdentifier:@"Test" sender:self];
}

I am getting this error

2013-09-03 23:33:21.234 Storyboard[946:c07] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Storyboard () doesn't contain a view controller with identifier 'Testing'' * First throw call stack: (0x1c92012 0x10cfe7e 0x45b679 0x2f14 0xc3285 0xc34ed 0xacd5b3 0x1c51376 0x1c50e06 0x1c38a82 0x1c37f44 0x1c37e1b 0x1bec7e3 0x1bec668 0x13ffc 0x28ed 0x2815) libc++abi.dylib: terminate called throwing an exception

I also tried

[test performSegueWithIdentifier:@"Test" sender:self];

But i am not able to find a proper code. Any help is appreciated.

Your table view is performing the segue, not the control you want to segue too. You probably want it to say:

[self performSegueWithIdentifier:@"Test" sender:self];

Also make sure your Segue has the proper ID:

在此输入图像描述

You don't have an ID for the view you want to push to. You need to go into the storyboard choose your view and set the Storyboard ID to Testing

在此输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM