您的位置:首页 > 产品设计 > UI/UE

iOS开发-UIActionSheet和UIAlertController

2016-02-29 00:16 836 查看
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];
/**
*
UIActionSheetStyleAutomatic
UIActionSheetStyleDefault
UIActionSheetStyleBlackTranslucent
UIActionSheetStyleBlackOpaque
*/
//这里的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];
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: