我試圖將選定的細胞標題傳遞給使用情節串聯板的視圖控制器,但它不像選擇細胞那樣容易。使用故事板將細胞標題傳遞到詳細信息視圖
我不知道如何確定當前選擇哪一個,並將它的標題傳遞給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)
。
這是我的問題 - 我該如何做到這一點,並將此標題傳遞給另一個視圖控制器使用它?
這就是我一直在尋找的東西。恥辱我以前沒有找到它!謝謝! – cojoj