Keeping MasterTableView row selected in SplitViewController

瘦欲@ 提交于 2019-12-23 02:32:37

问题


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

Keeping MasterViewController and DetailViewController in sync

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:

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

回答1:


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

self.clearsSelectionOnViewWillAppear = NO;


来源:https://stackoverflow.com/questions/10527504/keeping-mastertableview-row-selected-in-splitviewcontroller

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