#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.在 iOS 中获取 iPhone 位置,无需将“位置服务”设置为“开”
2.IOS8 CLLocationManager.h
我想在我的应用程序中打开(关闭)我的 iphone6 定位服务。但此代码在 IOS8 上不起作用。我不知道为什么。