Files
wnmj-normal/IosApi/LocationViewController.m
2026-03-03 13:56:44 +08:00

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