iOS UIAlertController的简单使用

2018-05-17  本文已影响32人  隔墙送来秋千影
UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"现有新版本app" message:@"请下载新版本后继续使用" preferredStyle:UIAlertControllerStyleAlert]; 
UIAlertAction *action1 = [UIAlertAction actionWithTitle:@"去下载" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
    NSString *appStr = @"https://itunes.apple.com/cn/app/id1234567890?mt=8";
    NSString *version = [UIDevice currentDevice].systemVersion;
    [[UIApplication sharedApplication] openURL:[NSURL URLWithString:appStr] options:@{UIApplicationOpenURLOptionUniversalLinksOnly:@""}
                                     completionHandler:nil];
}];

UIAlertAction *action2 = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:^(UIAlertAction * _Nonnull action) {
        
}];
    
[alert addAction:action1];
[alert addAction:action2];
[self presentViewController:alert animated:YES completion:nil];
上一篇 下一篇

猜你喜欢

热点阅读