【发布时间】:2014-01-27 16:48:41
【问题描述】:
在 didSelectRowAtIndexPath 中选择 segue 时,我收到了上述警告。这发生在 iPad 上。 iPhone 给出了不同的警告,我会看看对此的修复是否也可以修复另一个。
我在方法中有两个 segues。第一个作品没有事故。第二个拿起警告。我环顾了网络,并查看了其他人的解决方案。 nada,所以我在这里发帖..
这是代码:(我愿意接受更好的方法来编写它!)
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
//NSLog(@"%s", __FUNCTION__);
if ((indexPath.section == 0) || (indexPath.section == 1) || (indexPath.section == 2)) return;
if (indexPath.section > 4) return;
//Images THIS WORKS OK
if (indexPath.section == 3 && indexPath.row == 0) {
viewController1 = [[ViewController1 alloc] init];
[self performSegueWithIdentifier:@"detailToV1" sender:self];
[self.tableView reloadData];
}
if (indexPath.section == 3 && indexPath.row == 1) { // THIS REDULTS IN A WARNING
viewController2 = [[ViewController2 alloc] init];
[self performSegueWithIdentifier:@"detailToV2" sender:nil];
}
//Notes THIS WORKS OK BUT I HAD TO USE A NIB TO AVOID THE WARNING
if (indexPath.section == 4 && indexPath.row == 0) {
viewController3 = [[ViewController3 alloc] init];
[[self navigationController] pushViewController:viewController3 animated:YES];
[self.tableView reloadData];
}
}
【问题讨论】: