嗯..
我有桌面视图 - 在我的应用中设置详细视图。
主视图使用常规代码将数据传递到详细信息视图
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
self.savedSelectedIndexPath = [self.tableView indexPathForSelectedRow];
[self performSegueWithIdentifier:@"showDetail" sender:self];
}
-(void) prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender{
if ([segue.identifier isEqualToString:@"showDetail"]){
NSIndexPath *indexPath = self.savedSelectedIndexPath; //get the index path of the row selected
Event *event = [self.eventList objectAtIndex:indexPath.row]; // now get the content of that row
EventDetail *eventDetailView = (EventDetail *)segue.destinationViewController;
eventDetailView.eventDetail = event;
}
}
但由于某种原因,详细信息视图正在加载两次。 第一个加载看起来正常,后退按钮指向主视图。但是当第一次加载完成后,它会再次重新加载视图,后退按钮指向第一个加载..
当我在ViewDidLoad中运行NSLog时,我可以看到NSLog被记录两次......
我不确定为什么会这样做..
这是我在详细信息视图中的ViewDidLoad中所拥有的:
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view.
NSLog(@"page loaded");
self.eventTitleIB.text = eventDetail.eventTitle;
self.eventLocationIB.text = eventDetail.address;
self.eventTimeIB.text = eventDetail.eventTime;
self.eventPointsIB.text = eventDetail.points;
self.pointRuleIB.text = [NSString stringWithFormat: @"Single Event is worth %@ points", eventDetail.points];
self.eventDetailIB.text = eventDetail.eventDescription;
NSLog(@"content loaded");
}
谢谢大家的帮助!!
答案 0 :(得分:1)
是tableviewcell和detailviewcontroller之间链接的segue吗?在这种情况下,删除[self performSegueWithIdentifier:@" showDetail"发件人:自];