Add settings button for tvOS

This commit is contained in:
Cameron Gutman 2019-09-24 18:56:37 -07:00
parent 8ccbdc7923
commit d98aba66a8
3 changed files with 16 additions and 2 deletions

View File

@ -17,8 +17,8 @@
@interface MainFrameViewController : UICollectionViewController <DiscoveryCallback, PairCallback, HostCallback, AppCallback, AppAssetCallback, NSURLConnectionDelegate, SWRevealViewControllerDelegate> @interface MainFrameViewController : UICollectionViewController <DiscoveryCallback, PairCallback, HostCallback, AppCallback, AppAssetCallback, NSURLConnectionDelegate, SWRevealViewControllerDelegate>
#if !TARGET_OS_TV
@property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsButton; @property (weak, nonatomic) IBOutlet UIBarButtonItem *settingsButton;
#if !TARGET_OS_TV
@property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton; @property (weak, nonatomic) IBOutlet UIBarButtonItem *upButton;
#endif #endif

View File

@ -714,6 +714,10 @@ static NSMutableSet* hostList;
// if the user drags all the way off the screen opposite the settings pane. // if the user drags all the way off the screen opposite the settings pane.
self.revealViewController.bounceBackOnOverdraw = NO; self.revealViewController.bounceBackOnOverdraw = NO;
#else #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 // Restore focus on the selected app on view controller pop navigation
self.restoresFocusAfterTransition = NO; self.restoresFocusAfterTransition = NO;
self.collectionView.remembersLastFocusedIndexPath = YES; self.collectionView.remembersLastFocusedIndexPath = YES;
@ -762,6 +766,13 @@ static NSMutableSet* hostList;
[self.view addSubview:hostScrollView]; [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 -(void)beginForegroundRefresh:(bool)refreshAppList
{ {
if (!_background) { if (!_background) {

View File

@ -58,8 +58,11 @@
<outlet property="delegate" destination="vKn-MI-uG7" id="U6n-Uv-2Do"/> <outlet property="delegate" destination="vKn-MI-uG7" id="U6n-Uv-2Do"/>
</connections> </connections>
</collectionView> </collectionView>
<navigationItem key="navigationItem" id="4ja-Go-cNV"/> <navigationItem key="navigationItem" id="4ja-Go-cNV">
<barButtonItem key="leftBarButtonItem" title="Settings" id="Iii-CS-fMJ" userLabel="Settings"/>
</navigationItem>
<connections> <connections>
<outlet property="settingsButton" destination="Iii-CS-fMJ" id="32S-2R-fU5"/>
<segue destination="YUB-6u-B7f" kind="show" identifier="createStreamFrame" id="7lZ-Tj-a6a"/> <segue destination="YUB-6u-B7f" kind="show" identifier="createStreamFrame" id="7lZ-Tj-a6a"/>
</connections> </connections>
</collectionViewController> </collectionViewController>