Controller中保持MasterTableView行处于选

Controller中保持MasterTableView行处于选

本文介绍了在SplitViewController中保持MasterTableView行处于选中状态的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的SplitViewController中,基于DetailViewController中的操作,我基本上使用NSNotificationCenter更新MasterViewController行,如下所示:

In my SplitViewController, based on an action in the DetailViewController, I update the MasterViewController row using NSNotificationCenter essentially like this:

保持MasterViewController和DetailViewController同步

问题是,一旦完成对MasterViewController行的更新,就不再选择该行.当我使用splitViews查看Apple的iPad应用程序时,例如Note应用程序,总是选择一行.我想做同样的事情,所以我的两个表之间的所有内容都保持同步.由于具有tableView的indexPath,因此我可以手动在行上仅setSelected:YES animated:NO,但是在再次设置之前,我仍然看到所选行的蓝色高光闪烁.我不要

The problem is, once an update to the row of the MasterViewController is done, the row is no longer selected. When I look at Apple's iPad apps using splitViews, like the Note application, a row is always selected. I want to do the same thing so everything stays in sync between my two tables. I can manually just setSelected:YES animated:NO on the row since I have the indexPath of the tableView, but I still do see the blue highlight of the selected row flicker off before getting set on again. I don't want that.

MasterViewController:

MasterViewController:

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        Scene *object = [[[DataManager sharedInstance] sceneArray] objectAtIndex:indexPath.row];
        self.detailViewController.detailItem = object;
    }
}

推荐答案

这是关键-在UITableViewController上设置此属性:

This is the key - set this property on the UITableViewController:

self.clearsSelectionOnViewWillAppear = NO;

这篇关于在SplitViewController中保持MasterTableView行处于选中状态的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 13:00