iOS Master Detail app - detail shows only the first time

吃可爱长大的小学妹 提交于 2019-12-25 18:51:54

问题


I have lots of rows in the Master, the first time I click a row, the content is displayed in Details. I go back, choose a new row, or the same row, it displays "Detail view content goes here" in Details. I've traced like crazy, used NSLog just in case it's some kind of event reordering, used setNeedsDisplay in the view and in the UIControl instance. Everything is tracking out okay in the right order, but nothing is displaying the new content. NSLog shows the new content is in the control, just not being displayed. Any assistance would be welcome, this is driving me crazy.

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    if ([[segue identifier] isEqualToString:@"showDetail"]) {
        NSIndexPath *indexPath = [[self tableView] indexPathForSelectedRow];
        NSObject *object = [[[self objects] objectAtIndex:[indexPath section]] objectAtIndex:[indexPath row]];
        [[segue destinationViewController] setDetailItem:object];
    }
}

回答1:


I am updating by sending a message to the sender. I had included code to set the sender, e.g. the detail view, but assumed it wouldn't be changed after it was set. It turns out detail views are created new each time so the previous link would be invalid. Fixed it by simply resaving the sender every time the view is constructed.



来源:https://stackoverflow.com/questions/13084561/ios-master-detail-app-detail-shows-only-the-first-time

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!