本文主要是介绍iOS开发-UIActionSheet和UIAlertController,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
ActionSheet
- (void)buttonPressed:(id)sender
{/**UIActionSheet已经在8.3后被弃用了,如果想要去掉警告信息,可以把项目的Deployment Target设置为8.3以下,就可以去掉警告了。*//**Title:如果不想要title,可以设置为nil;注意需要实现UIActionSheetDelegate;destructiveButtonTitle:设置的按钮文字是红色的;otherButtonTitles:按照按钮顺序;*/UIActionSheet *actionSheet = [[UIActionSheet alloc] initWithTitle:@"这是标题" delegate:self cancelButtonTitle:@"取消" destructiveButtonTitle:@"确定" otherButtonTitles:nil];/***UIActionSheetStyleAutomaticUIActionSheetStyleDefaultUIActionSheetStyleBlackTranslucentUIActionSheetStyleBlackOpaque*///这里的actionSheetStyle也可以不设置;actionSheet.actionSheetStyle = UIActionSheetStyleAutomatic;[actionSheet showInView:self.view]; }
AlertController
- (void)buttonPressed1:(id)sender
{NSLog(@"dianji");// 初始化提示框UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"提示" message:@"Message" preferredStyle:UIAlertControllerStyleActionSheet];[alert addAction:[UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSLog(@"点击确定");}]];[alert addAction:[UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {NSLog(@"点击取消");}]];[self presentViewController:alert animated:true completion:nil];
}
这篇关于iOS开发-UIActionSheet和UIAlertController的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!