Tag: uialertcontroller

UIAlertControllerclosures他的presentationViewController

我想了解我的应用程序的一个奇怪的行为,这里是一个描述(在一个微不足道的项目中testing)。 ViewControllerA呈现模态ViewControllerB ViewControllerB包含一个button,这个button呈现一个这样指定的UIAlertController alert = [UIAlertController alertControllerWithTitle:@"Test" message:nil preferredStyle:UIAlertControllerStyleActionSheet]; [alert addAction:[UIAlertAction actionWithTitle:@"Action" style:UIAlertActionStyleDefault handler:^(UIAlertAction *handler) { NSLog(@"Action"); }]]; ViewControllerB以这种方式呈现警报 – (IBAction)button:(id)sender { alert.popoverPresentationController.sourceView = self.button; alert.popoverPresentationController.sourceRect = self.button.bounds; [self presentViewController:alert animated:YES completion:nil]; } 现在,如果您点击button,就会出现警报,如果您在警报外单击,警报消失(我在iPad上)。 你可以做很多次,只要你想… 这里是错误:当提示警报,如果你点击两次(足够快,〜0.2s的时间间隔),警报消失和ViewControllerB被解雇 。 最后我们可以看到ViewControllerA,但我们从来没有要求过。 还有一个警告信息: Warning: Attempt to dismiss from view controller <UIViewController: 0x7f85ab633f70> while a presentation or dismiss is in […]

带有白色边框的alertController

我创build了一个带有操作表和两个button的alertcontroller。 由于操作单将具有圆angular的边缘,在屏幕上的四个angular上出现白色。 我试着改变alertcontroller的背景颜色,但是这使得操作表变成了带有锐边而不是圆边框的矩形。 我试图设置视图背景颜色清除颜色尝试设置边框半径。 这是我的行动表。 我希望那些白色的边缘不可见。 此外,如何更改取消的背景颜色。 let cancelAction = UIAlertAction(title: "Cancel".localize(), style: .cancel) { _ in // this is where I am creating the cancelAction } 编辑 – 1:为alertcontroller添加代码 func showActionSheet(_ changeAction: UIAlertAction) { let alertController = UIAlertController(title: "", message: "Here is my alert text".localize(), preferredStyle: .actionSheet) alertController.view.tintColor = StyleKit.goldenColor let attributedString = NSAttributedString(string: […]

我如何显示从任何NSObject子类UIAlertController?

我有一个我正在pipe理的遗留代码库,它需要显示来自各地的警报消息。 这是可怕的做法,需要重构,但这不会很快发生。 在iOS 9中,我需要能够触发和忘记警报视图,并为我pipe理视图显示和排队。

在UIAlertController的文本字段中select文本

我需要在UIAlertController出现后立即select文本字段的文本。 但是,我在标准UITextField中select文本的方式在这里不起作用。 这是我的尝试,但我似乎无法得到它的工作。 let ac = UIAlertController(title: "Rename", message: nil, preferredStyle: .Alert) ac.addTextFieldWithConfigurationHandler({ [] (textField: UITextField) in textField.selectedTextRange = textField.textRangeFromPosition(textField.beginningOfDocument, toPosition: textField.endOfDocument) textField.text = "filename.dat" }) ac.addAction(UIAlertAction(title: "CANCEL", style: .Cancel, handler: nil)) ac.addAction(UIAlertAction(title: "OK", style: .Default, handler: { [] Void in // do something })) dispatch_async(dispatch_get_main_queue(), { self.presentViewController(ac, animated: true, completion: nil) }) 有任何想法吗?

解除模态视图控制器提供的UIAlertController

我似乎遇到了一个类似的问题在一个未解决的发布的问题: UIAlertController解雇他的presentsViewController 我在一个普通的UIViewController上展示了一个模态视图控制器。 然后我popup一个模式视图控制器的警报。 当我按下“ok”closures警报(由下面的代码生成)时,模态视图控制器也被解除。 UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action{ [self dismissViewControllerAnimated: YES completion: nil];}]; UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"Sign up problem." message:@"Some fields are empty. Please check your inputs and try again." preferredStyle:UIAlertControllerStyleAlert]; [alert addAction:ok]; [self presentViewController:alert animated:YES completion:nil]; 我怎样才能解雇警报? 我意识到我可以通过使用导航控制器types设置来避免这个问题,而隐藏导航栏,所以我得到了与模态视图控制器相同的感觉,但这似乎很愚蠢。 谢谢。

正在要求<_UIPopoverBackgroundVisualEffectView>设置其不透明度

我试图显示(AlertController)操作表。 但是我在控制台中变得越来越弱了“<_UIPopoverBackgroundVisualEffectView 0x7fd65ef76ec0>被要求使其不透明度动起来,这会导致效果中断,直到不透明度返回到1。 这是我的代码: – extension GroupDataView { func callDot (sender : UIButton) { let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) alert.addAction(UIAlertAction(title: "Edit Group", style: .default , handler:{ (action)in print("User click Edit Group") })) alert.addAction(UIAlertAction(title: "Create Folder", style: .default , handler:{ (action)in print("User click Create Folder button") })) alert.addAction(UIAlertAction(title: "Delete Group", style: .destructive […]

在swift中显示alertController中的textField

刚才我写了下面提供的代码。 我想为下面的代码产生输出,但是当我运行它时会崩溃,并显示nil 。 class ViewController: UIViewController ,UITableViewDataSource{ var names = [String]() @IBOutlet weak var tableView: UITableView! override func viewDidLoad() { super.viewDidLoad() title = "\"The List\"" tableView.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell") // Do any additional setup after loading the view, typically from a nib. } @IBAction func addName(sender: AnyObject) { let alert = UIAlertController(title: "New name", message: "Add […]

UIAlertController文本字段宽度比平常小

所以我有一个UIAlertController与一个UITextField为input添加,但由于某种原因,文本字段似乎比它应该小得多。 任何想法为什么? 这是截图 这是守则 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"This is title" message:@"This is message" preferredStyle:UIAlertControllerStyleAlert]; [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { textField.keyboardType = UIKeyboardTypeNumberPad; textField.placeholder = @"I am a placeholder"; }]; UIAlertAction *okAction = [UIAlertAction actionWithTitle:@"Submit" style:UIAlertActionStyleDefault handler:nil]; [alert addAction:okAction]; [self presentViewController:alert animated:YES completion:nil]; 谢谢!

如何在Swift中旋转UIAlertController

我有一个工作的UIAlertController ,但我想要alert.view 90度的alert.view 。 我该怎么做? 我的代码如下: let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .Alert) alert.addAction(UIAlertAction(title: "Okay", style: .Default){(action)->() in }) presentViewController(alert, animated: true) {} 我试图添加: alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) 但它不起作用。 谢谢 !

以编程方式切换到UIAlert控制器

我正在用swift创build一个注册对话框,其中有3个文本字段和一个Switch,并且我成功添加了三个文本字段两个Alert。 以下代码显示相同。 let alertController = UIAlertController(title: "Register", message: "", preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "Cancel", style: .Cancel) { (action) in // … exit(0) } alertController.addAction(cancelAction) let OKAction = UIAlertAction(title: "Sign UP", style: .Default) { (action) in // … let name0 = alertController.textFields![0] as UITextField print("Text field: \(name0.text)") let email1 = alertController.textFields![1] as UITextField print("Text […]