【发布时间】:2012-02-18 00:54:14
【问题描述】:
我有一个 NavigationController,其中有一个 TableView。电视中的单元格有一个“模态”segue,它指向一个 TableViewController(类:Details.h/.m)。当我选择单元格时,我会按预期进入 TableViewController。
但是我需要添加以下功能:
1) 推到目的地,这样我就得到了一个不错的后退按钮。
2)将所选单元格中的各种对象信息传递给目标TVC。
为此,我执行以下任务:
1) 将 segue 更改为“push”并给它一个标识符“segueToDetails”
2.1)在didSelectRowAtIndexPath方法中添加代码(下)
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"segueToDetails" sender:self];
}
2.2)在prepareForSegue方法中添加代码(下)
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
NSIndexPath *selectedIndexPath = [self.tableView indexPathForSelectedRow];
NSInteger rowNumber = selectedIndexPath.row;
myObject = (MyObject *) [myArray objectAtIndex:rowNumber];
Details *details = [segue destinationViewController];
details.detailsObject = myObject;
}
2.3) 确认对象信息正在传递到目的地我使用 NSLog 输出一些数据(下)
- (void)viewDidLoad
{
[super viewDidLoad];
NSLog(@"name: %@", detailsObject.name);
}
现在,当我运行项目并在表格中选择一个单元格时,我会被带到目标 TVC,我看到 NSLog 的输出很好。我还有一个不错的后退按钮。但是等等,当我点击返回时,我还有另一个返回按钮!单击该后退按钮然后将我返回到我最初来自的位置。每次我转到目标 TVC 时,调试器窗口都会显示此消息。
2012-01-24 13:55:58.240 MyApp[26875:11603] nested push animation can result in corrupted navigation bar
012-01-24 13:55:58.593 MyApp[26875:11603] Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted.
2012-01-24 13:55:58.593 MyApp[26875:11603] Unbalanced calls to begin/end appearance transitions for <SpotDetails: 0x7a7a370>.
关于如何解决此问题的任何建议?
PS - 我正在使用带有 ARC 的 Xcode 4.2,iOS 5
【问题讨论】:
标签: iphone objective-c ios storyboard segue