【发布时间】:2013-08-08 13:03:02
【问题描述】:
我正在尝试使用情节提要将选定的单元格标题传递给 deatil 视图控制器,但这并不容易,因为单元格的选择。
我不知道如何确定目前选择了哪一个并将其标题传递给详细视图属性。
我想我必须先使用prepareForSegue:sender(这是我得到所有东西的地方)然后在tableView:didSelectRowAtIndexPath 中调用performSegueWithIdentifier:sender:,对吧?
这是我的示例:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([[segue identifier] isEqualToString:@"projectDetailsSegue"]) {
AlbumViewController *destinationView = [segue destinationViewController];
NSIndexPath *selectedRowIndex = [self.tableView indexPathForSelectedRow];
UITableViewCell *selectedCell = [self.tableView cellForRowAtIndexPath:selectedRowIndex];
destinationView.projectTitle = selectedCell.textLabel.text;
}
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
[self performSegueWithIdentifier:@"projectDetailsSegue" sender:self];
}
当我在详细视图控制器中记录 projectTitle 时,它显示 (null)。
这是我的问题 - 我怎样才能做到这一点并将这个标题传递给另一个视图控制器以使用它?
【问题讨论】:
-
请看这个链接:appcoda.com/…希望对你有帮助。
-
这就是我要找的。可惜没早点发现!谢谢!
标签: ios storyboard uitableview segue