52 lines
1.7 KiB
Objective-C
52 lines
1.7 KiB
Objective-C
|
|
|
|
#import "LocationViewController.h"
|
|
|
|
@implementation LocationViewController
|
|
|
|
#pragma mark - Initialization
|
|
|
|
- (void)initTitle:(NSString *)title {
|
|
UILabel *titleLabel = [[UILabel alloc] init];
|
|
|
|
titleLabel.backgroundColor = [UIColor clearColor];
|
|
titleLabel.textColor = [UIColor whiteColor];
|
|
titleLabel.text = title;
|
|
[titleLabel sizeToFit];
|
|
|
|
self.navigationItem.titleView = titleLabel;
|
|
}
|
|
|
|
#pragma mark - Life Cycle
|
|
|
|
- (void)viewDidAppear:(BOOL)animated {
|
|
[super viewDidAppear:animated];
|
|
}
|
|
|
|
- (void)viewDidLoad {
|
|
[super viewDidLoad];
|
|
|
|
[self initTitle:self.title];
|
|
}
|
|
|
|
- (void)showTip {
|
|
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"定位权限未开启,是否开启?" preferredStyle: UIAlertControllerStyleAlert];
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"是" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
if( [[UIApplication sharedApplication]canOpenURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]] ) {
|
|
#if __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0
|
|
[[UIApplication sharedApplication]openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString] options:@{}completionHandler:^(BOOL success) {
|
|
}];
|
|
#elif __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_8_0
|
|
[[UIApplication sharedApplication] openURL:[NSURL URLWithString:UIApplicationOpenSettingsURLString]];
|
|
#endif
|
|
}
|
|
}]];
|
|
|
|
[alert addAction:[UIAlertAction actionWithTitle:@"否" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
|
|
}]];
|
|
|
|
[self presentViewController:alert animated:true completion:nil];
|
|
}
|
|
|
|
@end
|