From d98aba66a83fab670a2648665a49c799c8877420 Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 24 Sep 2019 18:56:37 -0700 Subject: [PATCH] Add settings button for tvOS --- Limelight/ViewControllers/MainFrameViewController.h | 2 +- Limelight/ViewControllers/MainFrameViewController.m | 11 +++++++++++ Moonlight TV/Base.lproj/Main.storyboard | 5 ++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/Limelight/ViewControllers/MainFrameViewController.h b/Limelight/ViewControllers/MainFrameViewController.h index 9e986a8..5461ec9 100644 --- a/Limelight/ViewControllers/MainFrameViewController.h +++ b/Limelight/ViewControllers/MainFrameViewController.h @@ -17,8 +17,8 @@ @interface MainFrameViewController : UICollectionViewController -#if !TARGET_OS_TV @property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsButton; +#if !TARGET_OS_TV @property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton; #endif diff --git a/Limelight/ViewControllers/MainFrameViewController.m b/Limelight/ViewControllers/MainFrameViewController.m index efdd14a..bc9d33d 100644 --- a/Limelight/ViewControllers/MainFrameViewController.m +++ b/Limelight/ViewControllers/MainFrameViewController.m @@ -714,6 +714,10 @@ static NSMutableSet* hostList; // if the user drags all the way off the screen opposite the settings pane. self.revealViewController.bounceBackOnOverdraw = NO; #else + // The settings button will direct the user into the Settings app on tvOS + [_settingsButton setTarget:self]; + [_settingsButton setAction:@selector(openTvSettings:)]; + // Restore focus on the selected app on view controller pop navigation self.restoresFocusAfterTransition = NO; self.collectionView.remembersLastFocusedIndexPath = YES; @@ -762,6 +766,13 @@ static NSMutableSet* hostList; [self.view addSubview:hostScrollView]; } +#if TARGET_OS_TV +- (void)openTvSettings:(id)sender +{ + [[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{} completionHandler:nil]; +} +#endif + -(void)beginForegroundRefresh:(bool)refreshAppList { if (!_background) { diff --git a/Moonlight TV/Base.lproj/Main.storyboard b/Moonlight TV/Base.lproj/Main.storyboard index 93044e0..e320867 100644 --- a/Moonlight TV/Base.lproj/Main.storyboard +++ b/Moonlight TV/Base.lproj/Main.storyboard @@ -58,8 +58,11 @@ - + + + +