Allow tvOS to back out from app grid to PC grid

This commit is contained in:
Cameron Gutman
2018-08-26 15:05:32 -07:00
parent f988ce0278
commit 1b681a8730

View File

@@ -48,7 +48,9 @@
NSArray* _sortedAppList;
NSCache* _boxArtCache;
bool _background;
#if !TARGET_OS_TV
#if TARGET_OS_TV
UITapGestureRecognizer* _menuRecognizer;
#else
UIButton* _pullArrow;
#endif
}
@@ -231,6 +233,12 @@ static NSMutableSet* hostList;
}
- (void)showHostSelectionView {
#if TARGET_OS_TV
// Remove the menu button intercept to allow the app to exit
// when at the host selection view.
[self.view removeGestureRecognizer:_menuRecognizer];
#endif
[_appManager stopRetrieving];
_selectedHost = nil;
_computerNameButton.title = @"No Host Selected";
@@ -276,6 +284,11 @@ static NSMutableSet* hostList;
_selectedHost = host;
[self disableNavigation];
#if TARGET_OS_TV
// Intercept the menu key to go back to the host page
[self.view addGestureRecognizer:_menuRecognizer];
#endif
// If we are online, paired, and have a cached app list, skip straight
// to the app grid without a loading frame. This is the fast path that users
// should hit most. Check for a valid view because we don't want to hit the fast
@@ -663,6 +676,10 @@ static NSMutableSet* hostList;
// Get callbacks associated with the viewController
[self.revealViewController setDelegate:self];
#else
_menuRecognizer = [[UITapGestureRecognizer alloc] init];
[_menuRecognizer addTarget:self action: @selector(showHostSelectionView)];
_menuRecognizer.allowedPressTypes = [[NSArray alloc] initWithObjects:[NSNumber numberWithLong:UIPressTypeMenu], nil];
#endif
_loadingFrame = [self.storyboard instantiateViewControllerWithIdentifier:@"loadingFrame"];