From 4ce730490c3ccaa773bd66e74626ac9cdc5912e8 Mon Sep 17 00:00:00 2001 From: Sami Samhuri Date: Sun, 28 Jun 2015 13:29:54 -0700 Subject: [PATCH] fix clearing post selection on compact horiz layouts --- Blog/BlogSplitViewController.m | 9 +++++++++ Blog/PostsViewController.m | 3 +-- 2 files changed, 10 insertions(+), 2 deletions(-) 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) {