iOS UIAlertController的简单使用

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];

你可能感兴趣的:(iOS UIAlertController的简单使用)