本文介绍了iOS Master Detail应用程序-详细信息仅在第一次显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在母版中有很多行,第一次单击一行时,内容显示在详细信息"中.我返回,选择一个新行,或同一行,它在详细信息"中显示详细信息视图内容在此处".我曾经疯狂地追踪过,为了防止某种事件重新排序而使用了NSLog,在视图和UIControl实例中使用了setNeedsDisplay.一切都以正确的顺序进行,但是没有任何东西可以显示新内容. NSLog显示新内容在控件中,只是不显示.任何帮助都将受到欢迎,这使我发疯.

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];
    }
}

推荐答案

我正在通过向发件人发送消息来进行更新.我已经包含了设置发件人的代码,例如详细视图,但假定在设置后将不会对其进行更改.事实证明,每次都会创建新的详细视图,因此先前的链接将无效.通过在每次构造视图时简单地重新保存发件人来解决此问题.

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.

这篇关于iOS Master Detail应用程序-详细信息仅在第一次显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 00:07