How to use UIAlertView in iOS
This article mainly introduces how to use UIAlertView in iOS. It is very detailed and has a certain reference value. Friends who are interested must finish it!
NS_CLASS_DEPRECATED_IOS (2: 0, 9: 0, "UIAlertView is deprecated. Use UIAlertController with a preferredStyle of UIAlertControllerStyleAlert instead") _ _ TVOS_PROHIBITED
It probably means that after 9, it was still UIAlertView before using UIAlertController instead of UIAlertView,9.
Double version = [[UIDevice currentDevice] .systemVersion doubleValue]; / / determine the system version.
If (version > = 9.0f) {
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@ "prompt" message:nil preferredStyle:UIAlertControllerStyleAlert]
[alertController addAction: [UIAlertAction actionWithTitle:@ "OK" style:UIAlertActionStyleDefault handler: ^ (UIAlertAction * _ Nonnull action) {
NSLog (@ "OK")
}]]
[alertController addAction: [UIAlertAction actionWithTitle:@ "cancel" style:UIAlertActionStyleDefault handler: ^ (UIAlertAction * _ Nonnull action) {
NSLog (@ "cancel")
}]]
[self presentViewController:alertController animated:YES completion:nil]
} else {
UIAlertView * alertView = [[UIAlertView alloc] initWithTitle:@ "prompt" message:nil delegate:self cancelButtonTitle:nil otherButtonTitles:@ "OK, @" cancel ", nil]
[alertView show]
}
# pragma mark UIAlertView Click event
-(void) alertView: (UIAlertView *) alertView clickedButtonAtIndex: (NSInteger) buttonIndex NS_DEPRECATED_IOS (2: 0, 9: 0) {
NSLog (@ "% @", @ (buttonIndex))
}
The above is all the contents of the article "how to use UIAlertView in iOS". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!