- (void)showOkayCancelAlert { NSString *title = NSLocalizedString(@"A Short Title Is Best", nil); NSString *message = NSLocalizedString(@"A message should be a short, complete sentence.", nil); NSString *cancelButtonTitle = NSLocalizedString(@"Cancel", nil); NSString *otherButtonTitle = NSLocalizedString(@"OK", nil); UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAl ert]; // Create the actions. UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelButtonTitle style:UIAlertActionStyleCancel handler:^(UIAlertAction *action) { NSLog(@"The \"Okay/Cancel\" alert's cancel action occured."); }]; UIAlertAction *otherAction = [UIAlertAction actionWithTitle:otherButtonTitle style:UIAlertActionStyleDefaul t handler:^(UIAlertAction *action) { NSLog(@"The \"Okay/Cancel\" alert's other action occured."); }]; // Add the actions. [alertController addAction:cancelAction]; [alertController addAction:otherAction]; [self presentViewController:alertController animated:YES completion:nil]; }
IOS开发之 ---- iOS8中提示框的使用UIAlertController(UIAlertView和UIActionSheet二合一)
最新推荐文章于 2021-01-30 12:03:24 发布
本文介绍了一个使用 Swift 在 iOS 应用中展示带有确认和取消按钮的 UIAlertController 的具体示例。展示了如何设置 UIAlertController 的标题、消息,并为其添加两种不同类型的按钮。
6120

被折叠的 条评论
为什么被折叠?



