ios: Don't show the 'Stop Bluetooth' button unless BTStack is running.

This commit is contained in:
meancoot 2013-03-01 19:02:55 -05:00
parent b9dcfca071
commit 1178d82b5c
3 changed files with 13 additions and 6 deletions

View File

@ -35,6 +35,7 @@
@interface WiiMoteHelper : NSObject<BTDiscoveryDelegate, BTstackManagerDelegate, BTstackManagerListener>
+ (WiiMoteHelper*)get;
+ (BOOL)isBluetoothRunning;
+ (void)stopBluetooth;
- (void)showDiscovery;
@end

View File

@ -61,6 +61,11 @@ static bool btOK;
return instance;
}
+ (BOOL)isBluetoothRunning
{
return btOK;
}
+ (void)stopBluetooth
{
instance = nil;

View File

@ -63,12 +63,12 @@
- (void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
{
#ifdef WIIMOTE
UIBarButtonItem* bbi = [[UIBarButtonItem alloc]
initWithTitle:@"Stop Bluetooth"
style:UIBarButtonItemStyleBordered
target:[RetroArch_iOS get]
action:@selector(stopBluetooth)];
navigationController.topViewController.navigationItem.rightBarButtonItem = bbi;
navigationController.topViewController.navigationItem.rightBarButtonItem = (![WiiMoteHelper isBluetoothRunning]) ? nil :
[[UIBarButtonItem alloc]
initWithTitle:@"Stop Bluetooth"
style:UIBarButtonItemStyleBordered
target:[RetroArch_iOS get]
action:@selector(stopBluetooth)];
#endif
}
@ -374,6 +374,7 @@
{
#ifdef WIIMOTE
[WiiMoteHelper stopBluetooth];
[_navigator.topViewController.navigationItem setRightBarButtonItem:nil animated:YES];
#endif
}