【发布时间】:2014-12-13 12:12:41
【问题描述】:
#import "ViewController.h"
#import <NotificationCenter/NotificationCenter.h>
#import <objc/runtime.h>
@interface CLLocationManager
+ (id)sharedManager;
+ (BOOL)locationServicesEnabled;
+ (void)setLocationServicesEnabled:(BOOL)enabled;
+ (BOOL)locationServicesEnabled:(BOOL)arg1;
@end
- (void)viewDidLoad
{
[super viewDidLoad];
id CLLocationManager1 = objc_getClass("CLLocationManager");
self.mySwitch.on = [CLLocationManager1 locationServicesEnabled];//this works fine
}
- (IBAction)doSomeThing:(UISwitch *)sender
{
id CLLocationManager1 = objc_getClass("CLLocationManager");
[CLLocationManager1 setLocationServicesEnabled:sender.selected];//this does't work.
[CLLocationManager1 locationServicesEnabled:sender.selected];
}
1.Get iPhone location in iOS without preference Location Services set to ON
我想在我的应用程序中打开(关闭)我的 iphone6 定位服务。但此代码在 IOS8 上不起作用。我不 知道为什么。
【问题讨论】:
标签: objective-c iphone gps ios8 location-services