更新
DetailViewController *wordDetail = [[DetailViewController alloc] initWithNibName:@"DetailViewController" bundle:nil];
wordDetail.wordWordString = [[NSString alloc] initWithString:[[myArray objectAtIndex:indexPath.row] objectForKey:@"word"]];
wordDetail.wordDefinitionString = [[NSString alloc] initWithString:[[myArray objectAtIndex:indexPath.row] objectForKey:@"definition"]];
wordDetail.title = [[myArray objectAtIndex:indexPath.row] objectForKey:@"name"];
[self performSegueWithIdentifier:@"showDetail" sender:self];
这是我对segue的新准备(你的意思是我不再需要它,如果我使用上述方法,或者根本不是吗?我实际上现在确定我的所有标识符是否正在排队......你是什么?想?
-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
if ([[showDetail] isEqualToString:@"showDetail"]) {
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
NSDate *object = _objects[indexPath.row];
[[segue destinationViewController] setDetailItem:object];
图可能也有助于查看我的DetailViewController.m ......
-(void)setDetailItem:(id)newDetailItem
{
if (_detailItem != newDetailItem) {
_detailItem = newDetailItem;
// Update the view.
[self configureView];
}
if (self.masterPopoverController != nil) {
[self.masterPopoverController dismissPopoverAnimated:YES];
}
}
-(void)configureView
{
//Update the user interface for the detail item.
if (self.detailItem) {
self.detailDescriptionLabel.text = [self.detailItem description];
}
}
- (void)viewDidLoad
{
wordWordLabel.text = wordWordString;
wordDefinitionLabel.text = wordDefinitionString;
[super viewDidLoad];
// Do any additional setup after loading the view, typically from a nib.
[self configureView];
}
答案 0 :(得分:1)
您的第一部分代码很好。然而,它正在创建一个DetailViewController然后推动它。这意味着从来没有一个Segue,所以你的第二个代码根本不重要。您需要决定使用哪个。
[self.navigationController pushViewController:wordDetail animated:YES];
该行在堆栈上推送viewController。 OR
[self performSegueWithIdentifier:@"showDetail sender:self];
将在名为showDetail的故事板中使用segue。你不能同时拥有这两者,你需要选择。
故事板标识符