从UITableViewCell到另一个ViewController

时间:2013-09-03 17:59:16

标签: iphone ios objective-c

我创建了一个带有故事板的Single view application,我拖了一个TableView。我可以对tableview进行充气并获取一些数据,但点击任意UITableViewCell我需要转到下一个ViewController。我将另一个ViewController拖放到了故事板,并将MainViewController与新创建的ViewController相关联。我需要从didSelectRowAtIndexPath方法

转到新的View控制器

我尝试使用此

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

我收到此错误

  

2013-09-03 23:33:21.234故事板[946:c07] *终止应用程序   未捕获的异常'NSInvalidArgumentException',原因:'故事板   ()不包含视图控制器   标识符'测试''   * 第一次抛出调用堆栈:(0x1c92012 0x10cfe7e 0x45b679 0x2f14 0xc3285 0xc34ed 0xacd5b3 0x1c51376 0x1c50e06 0x1c38a82 0x1c37f44   0x1c37e1b 0x1bec7e3 0x1bec668 0x13ffc 0x28ed 0x2815)libc ++ abi.dylib:   终止调用抛出异常

我也试过

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

但我无法找到合适的代码。任何帮助表示赞赏。

2 个答案:

答案 0 :(得分:4)

您的表格视图正在执行segue,而不是您想要进行的控制。你可能想要它说:

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

还要确保您的Segue具有正确的ID:

enter image description here

答案 1 :(得分:0)

您没有要推送的视图的ID。您需要进入故事板选择视图并将故事板ID设置为Testing

enter image description here

相关问题