【发布时间】:2013-10-12 18:45:12
【问题描述】:
我在UINavigationController 中嵌入了两个UITableViews。在第一个 table viewcontroller 中选择一个单元格应该触发一个 push segue 到第二个。未执行此 segue。
FirstTableVC
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
// getting called as planned
if (indexPath.row == 0 && reload == YES) {
// working
[self pushedRefresh:self];
reload = NO;
return;
}
NSLog(@"past return"); // logged as planned
// NOT performing!
[self performSegueWithIdentifier:@"more" sender:[self.tableView cellForRowAtIndexPath:indexPath]];
}
我做了什么/注意到了
-
SecondTblVC'sviewDidLoad:方法未被调用。但是,如果我使用非推送 segue,VC 会正确显示。 - 我尝试在
performSegueWithIdentifier:的发送者参数中使用nil和self,结果相同。 - 我已将第二个视图控制器转换为原版
UIViewController,结果相同。 - “更多”转场正确标记并连接为
push - 没有崩溃,只是缺少segue。
- 我已删除情节提要中的整个
UINavigationController设置,并将其替换为相同的结果。 - 我确实没有有一个单独的.h/.m 用于
UINavigationController - 表格视图
delegates/data source链接正在按计划工作。 -
有一个
destinationViewController(通过登录performSegue方法得知)。
如果更多代码和屏幕截图有帮助,请告诉我。
谢谢。
编辑
这是我的cellForRowAtIndexPath 实现:
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"ReuseCell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
cell.textLabel.text = [clubNames objectAtIndex:indexPath.row];
cell.detailTextLabel.text = [times objectAtIndex:indexPath.row];
if (cell == nil)
{
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:simpleTableIdentifier];
}
[cell setAccessoryType:UITableViewCellAccessoryDisclosureIndicator];
return cell;
}
【问题讨论】:
-
你是如何在故事板中创建转场的?
-
从 UITableViewCell 拖到 SecondTblVC 并选择 push。
-
好的,所以你根本不需要输入 [self performSegue...] 行。如果它是从 UITableViewCell 连接的,那么选择单元格无论如何都会调用 segue。只需删除该行。
-
好的。已删除,但没有变化。
-
我建议阅读 Ray wenderlich 网站上关于使用故事板的教程。它将引导您完成此操作。
标签: objective-c uitableview uinavigationcontroller pushviewcontroller