diff --git a/Blog/BlogSplitViewController.m b/Blog/BlogSplitViewController.m index b8ab9c9..cef8dc0 100644 --- a/Blog/BlogSplitViewController.m +++ b/Blog/BlogSplitViewController.m @@ -22,8 +22,17 @@ self.postsViewController.preferredContentSize = CGSizeMake(320, 600); } +- (void)viewWillAppear:(BOOL)animated { + [super viewWillAppear:animated]; + [self updateForNewTraitCollection:self.traitCollection]; +} + - (void)willTransitionToTraitCollection:(UITraitCollection *)newCollection withTransitionCoordinator:(id )coordinator { [super willTransitionToTraitCollection:newCollection withTransitionCoordinator:coordinator]; + [self updateForNewTraitCollection:newCollection]; +} + +- (void)updateForNewTraitCollection:(UITraitCollection *)newCollection { BOOL isCompact = newCollection.horizontalSizeClass == UIUserInterfaceSizeClassCompact; self.postsViewController.clearsSelectionOnViewWillAppear = isCompact; } diff --git a/Blog/PostsViewController.m b/Blog/PostsViewController.m index 9117015..dff7e7d 100644 --- a/Blog/PostsViewController.m +++ b/Blog/PostsViewController.m @@ -194,8 +194,7 @@ static const NSUInteger SectionPublished = 1; - (void)viewWillAppear:(BOOL)animated { [super viewWillAppear:animated]; [self requestStatusWithCaching:YES]; - BOOL isPhone = [UIDevice currentDevice].userInterfaceIdiom == UIUserInterfaceIdiomPhone; - if (isPhone && self.tableView.indexPathForSelectedRow) { + if (self.clearsSelectionOnViewWillAppear && self.tableView.indexPathForSelectedRow) { [self.tableView deselectRowAtIndexPath:self.tableView.indexPathForSelectedRow animated:YES]; } if (!self.postCollections) {