iOS 自带三种提示框使用、UIAlertView以及UIAlertController的使用
UIActionSheet *actionSheet = [[UIActionSheet alloc]
initWithTitle:address
delegate:self
cancelButtonTitle:@"取消"
destructiveButtonTitle:nil
otherButtonTitles:@"高德地图中导航",@"苹果地图中导航",nil];//按钮显示可以设置多个按钮显示
actionSheet.actionSheetStyle = UIActionSheetStyleBlackOpaque;//设置样式
[actionSheet showInView:self.view];
#pragma mark 打开地图导航
-(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex{
if (buttonIndex == 0) {
}else if(buttonIndex== 1) {
}else if(buttonIndex == 2) {
}
. . . . . . . . .
}
<UIActionSheetDelegate>
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:title
message:message
delegate:self
cancelButtonTitle:@"取消"
otherButtonTitles:@"确定", nil];
[alert show];
- (void)alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex{//点击弹窗按钮后
if (buttonIndex == 0) {//取消
}else if (buttonIndex == 1){//确定
}
}
UIAlertController * alertController = [UIAlertController alertControllerWithTitle:@"" message:[NSString stringWithFormat:@"总分:%d",_count*100] preferredStyle:UIAlertControllerStyleAlert];
UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"再玩一次" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnullaction) {
}];
[alertController addAction:cancelAction];
[alertController addAction:okAction];
[self presentViewController:alertController animated:YES completion:nil];