Tag: uialertcontroller

dismissViewControllerAnimated在块内不起作用

在显示UIAlertController后,我尝试closures一个UIViewController 。 这是我的代码: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Accept" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self dismissViewControllerAnimated:YES completion:nil]; }]; [alertController addAction:okAction]; [self presentViewController:alertController animated:YES completion:^{}]; 但是, self永远不会被解雇。 有人知道如何解决这个问题? UPDATE 如果我设置[self dismissViewControllerAnimated:YES completion:nil]; 在块之外,它的工作。

如何在警报控制器的文本字段中使用数字键盘

我正在尝试调用一个具有文本字段的警报控制器。 但是我想立即显示数字键盘,因为用户只需要input数字。 我尝试了以下,但它不工作。 let alert = UIAlertController(title: "New Rating", message: "Rate this!", preferredStyle: UIAlertControllerStyle.Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Default, handler: { (action: UIAlertAction!) in }) let saveAction = UIAlertAction(title: "Save", style: .Default, handler: { (action: UIAlertAction!) in let textField = alert.textFields![0] as UITextField textField.keyboardType = UIKeyboardType.NumberPad self.updateRating(textField.text) }) alert.addTextFieldWithConfigurationHandler { (textField: UITextField!) in […]

无法selectUIAlertController中button的顺序

我的印象是,如果正常的行为是一个破坏性的行为,另一个是在他们的UIAlertController取消行动,破坏性的应该在左边,取消应该在右边。 如果正常行为不具有破坏性,那么正常行为应该在右边,取消应该在左边。 这就是说,我有以下几点: var confirmLeaveAlert = UIAlertController(title: "Leave", message: "Are you sure you want to leave?", preferredStyle: .Alert) let leaveAction = UIAlertAction(title: "Leave", style: .Destructive, handler: { (alert: UIAlertAction!) in //Handle leave } ) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) confirmLeaveAlert.addAction(leaveAction) confirmLeaveAlert.addAction(cancelAction) self.presentViewController(confirmLeaveAlert, animated: true, completion: nil) 我的印象是,如果我先添加了leaveAction ,那么cancelAction就是左边的button。 此情况并非如此。 我尝试以相反的顺序添加button,也导致按相同顺序添加button。 我错了吗? […]

泄漏与UIAlertController

我添加UIAlertController在我的应用程序通过创buildUIViewController类别与以下方法: – (void)showAlertViewWithTitle:(NSString *)title message:(NSString *)message actions:(NSArray *)alertActions { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title ? : @"" message:message preferredStyle:UIAlertControllerStyleAlert]; if (alertActions.count) { for (UIAlertAction *action in alertActions) { [alertController addAction:action]; } } else { UIAlertAction *action = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; [alertController addAction:action]; } [self presentViewController:alertController animated:YES completion:nil]; } 起初,一切看起来不错,但是当我用仪器分析泄漏时,每次我调用这个方法时,都会出现一些泄漏: 以下是如何调用showAlertViewWithTitle:message:actions:完成的 [self showAlertViewWithTitle:nil message:@"Test message" […]

UIAlertController着色颜色默认为蓝色

我使用下面的代码来呈现一个UIAlertController操作表,其中的项目文本为红色。 我使用了tint属性来设置颜色。 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:nil message:nil preferredStyle:UIAlertControllerStyleActionSheet]; alertController.view.tintColor = [UIColor redColor]; 文本颜色似乎是默认为高亮或select蓝色。 这是正常的,我该怎么办?

如何在Swift ios中创build自定义UIAlertController?

我正在试图使UIAlertController看起来像这样: 我们如何定制UIAlertController来获得与此图片相同的结果?

仅在input后启用UIAlertController的UIAlertAction

我正在使用UIAlertController来显示一个对话框,其中包含一个UITextField和一个标有“Ok”的UIAlertActionbutton。 如何禁用该button,直到input到UITextField的字符(如5个字符)为止?

当它调用“presentViewController:”时,UIAlertController被移动到屏幕顶部的马车位置

从UIAlertController呈现视图会将警报移动到屏幕左上angular的马车位置。 iOS 8.1,设备和模拟器。 我们在一个应用程序中注意到这一点,当我们试图从目前的“最顶级”的观点提出一个看法。 如果一个UIAlertController碰巧是最顶层的视图,我们会得到这种行为。 我们已经改变了我们的代码来简单地忽略UIAlertControllers,但我发布这个以防其他人碰到同样的问题(因为我什么都找不到)。 我们已经将这个问题隔离到一个简单的testing项目上,在这个问题的底部给出完整的代码 在新的Single View Xcode项目中实现viewDidAppear:在视图控制器上。 提供一个UIAlertController警报。 警报控制器立即调用presentViewController:animated:completion:显示然后closures另一个视图控制器: 在presentViewController:…animation开始的那一刻,UIAlertController被移动到屏幕的左上angular: 当dismissViewControllerAnimated:animation结束时,警报已经进一步移动到屏幕的左上angular: 完整代码: – (void)viewDidAppear:(BOOL)animated { // Display a UIAlertController alert NSString *message = @"This UIAlertController will be moved to the top of the screen if it calls `presentViewController:`"; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"UIAlertController iOS 8.1" message:message preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:[UIAlertAction actionWithTitle:@"I think that's […]

UIAlertController处理忽略外部(IPad)

在iOS8之前,我们使用UIActionSheet来显示警报,现在我们需要使用UIAlertController。 当我们使用UIActionSheet时,我们可以很容易地处理用户在popup窗口之外单击的情况(这意味着他想要取消操作),通过比较clickedButtonAtIndex和cancelButtonIndex – 如果用户的确在button之外按下了button索引在这个function。 我们如何使用新的UIAlertController来处理这些情况? 我试图使用“完成”块,但它没有任何上下文。 有一个简单的方法来处理这个? (除了“保存”一些常规variables中的动作状态之外)。

如何在UIAlertController中隐藏标题/消息框?

当使用UIAlertController ,如果我想提供一个空标题和一个空信息的UIActionSheet ,标题和/或消息的预期位置的框架将保留。 我如何改变这个,所以我只提出一个ActionSheet ,内容如下: 设置 登出 取消? 谢谢!