Tag: uialertcontroller

在ViewController之外显示UIAlertController

我有麻烦显示我的UIAlertController,因为我试图显示它不是一个ViewController类。 我已经尝试添加它: var alertController = UIAlertController(title: "Title", message: "Message", preferredStyle: .Alert) UIApplication.sharedApplication().keyWindow?.rootViewController?.presentViewController(alertController, animated: true, completion: nil) 哪个不工作…我没有find任何解决scheme,为我工作呢。

是否应该在UIAlertAction的处理程序中把自己强加给?

在编写UIAlertAction的handler闭包时,对self的引用是否应该是强壮的(默认), weak还是unowned ? 有一些post与这个话题有关( 1,2,3,4 ),但是我真的不明白他们在这种情况下如何提供帮助。 我们来关注一下这个典型的代码: func tappedQuitButton() { let alert = UIAlertController(title: "Confirm quit", message: nil, preferredStyle: .ActionSheet) let quitAction = UIAlertAction(title: "Quit", style: .Default) { (action) in self.dismissViewControllerAnimated(true, completion: nil) } alert.addAction(quitAction) let cancelAction = UIAlertAction(title: "Cancel", style: .Default) { (action) in self.dismissViewControllerAnimated(true, completion: nil) } alert.addAction(cancelAction) presentViewController(alert, animated: true, completion: nil) […]

在哪里可以find关于快速警报(UIAlertController)的清晰解释?

找不到一个明确的和翔实的解释。

将checkbox列表添加到UIAlertController

我正在使用UIAlertController 。 现在我可以从下面的代码中列出一个项目: { UIAlertController *controller = [UIAlertController alertControllerWithTitle: @"Beds" message: @"" preferredStyle: UIAlertControllerStyleAlert]; [controller.view setBackgroundColor:[UIColor clearColor]]; [controller.view setTintColor:[UIColor blackColor]]; for (int a=0;a<[bedsCount count];a++) { UIAlertAction *button = [UIAlertAction actionWithTitle: [bedsCount objectAtIndex:a] style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [bedSelectionText setTitle:[bedsCount objectAtIndex:a] forState:UIControlStateNormal]; }]; [controller addAction: button]; } 我想在下面的链接显示的格式显示button单击UIAlertController上的列表: View post on imgur.com

Swift – 如何在自定义AlertController中点击button时呈现ViewController

我正在Swift 2.3中开发 我有一个Utils类,使我能够轻松地创buildUIAlertController。 public class Utils { class func buildAlertInfo(withTitle title: String?, andMessage message: String?, withHandler handler: (UIAlertAction -> Void)?) -> UIAlertController { let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: handler)) return alertController } } 它使我能够轻松构buildAlertController: let alert = Utils.buildAlertInfo(withTitle: "Information", andMessage: "John Snow is dying", withHandler: nil) […]

如何从SKScene展示UIAlertController

我在Spritekit工作,我试图从我的SKScene提出一个UIAlertController,但我遇到麻烦。 我看过几个教程,但是没有一个UIAlertController教程是专门针对Spritekit的。 我不断地看到下面的代码,但它并没有效果,因为SKScene不是一个UIViewController。 [self presentViewController:self animated:YES completion:nil]; 我有下面的相关代码的其余部分。 任何人都可以帮我在我的SKScene上展示我的UIAlerController。 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"You Lose!" message:@"Do You Want To Beat This Level?" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *CancelButton = [UIAlertAction actionWithTitle:@"GiveUp" style:UIAlertControllerStyleAlert handler:<#^(UIAlertAction *action)handler#>]

如何滚动通知控制器中的操作? Xcode 8,Swift 3,IOS

请帮忙! :)我是一个巨大的noobie在这里。 我从各种来源收集这些代码,所以我不知道我在做什么。 我的提醒控制器显示一个我可以写入的文本框,一个“取消”操作,一个“确定”操作,还显示多个“input关键字到标签”操作。 它有很多动作(我需要大约20个关键字动作),它们不适合在屏幕上,它被键盘覆盖,或者是在键盘的方式。 它看起来很丑,一些你不能触摸的button。 有没有办法滚动我的行动,使其适合这个空间? 这是我最后一张图片的代码: //Quality Text Box (9) @IBOutlet weak var QualityLabel: UILabel! @IBAction func QualityTapped(_ sender: UIButton) { print("Quality Button Tapped") openQualityAlert() } func openQualityAlert() { //Create Alert Controller let alert9 = UIAlertController (title: "Quality:", message: nil, preferredStyle: UIAlertControllerStyle.alert) //Create "Keyword -> label" actions let bt1 = UIAlertAction(title: "Abuse", style: […]

在GameScene中显示一个UIAlertController(SpriteKit / Swift)

在swift中显示UIAlertView的简单方法是: let alert = UIAlertView() alert.title = "Alert!" alert.message = "A wise message" alert.addButtonWithTitle("Ok, thank you") alert.show() 但是现在在iOS 9中这已经被折旧了,build议使用UIAlertController : let myAlert: UIAlertController = UIAlertController(title: "Alert!", message: "Oh! Fancy", preferredStyle: .Alert) myAlert.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil)) self.presentViewController(myAlert, animated: true, completion: nil) 这是伟大的,但我使用SpriteKit和一个GameScene,这给出了一个Value of type 'GameScene' has no member 'presentViewController'的Value of type 'GameScene' has no […]

UIAlertController – 更改文本字段的大小并在它们之间添加空格

我的警报看起来像这样: 是否有可能使input变大并在它们之间增加空间? 这是我的代码的例子。 我试图改变第二个textField的框架属性,但没有帮助: let alert = UIAlertController(title: title, message: message, preferredStyle: .Alert) // Add the textfields alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in textField.placeholder = "Vaše jméno" }) alert.addTextFieldWithConfigurationHandler({ (textField) -> Void in textField.placeholder = "Společné heslo" var oldFrame = textField.frame oldFrame.origin.y = 40 oldFrame.size.height = 60 textField.frame = oldFrame })

UIAlertController中的自定义视图

我正在尝试在UIAlertController放置一个自定义视图。 我遇到了一些与自定义视图大小有关的奇怪问题。 我想要自定义视图跨越UIAlertController的宽度,无论可能。 我正在使用CGRectGetWidth(alertController.view.bounds)来获取警报控制器的宽度。 但是,这似乎是返回整个视图的宽度。 使用view.frame没有什么区别。 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"My Title" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIView *view = [[UIView alloc] initWithFrame:CGRectMake(0, 0, CGRectGetWidth(alertController.view.bounds), 50)]; view.backgroundColor = [UIColor blueColor]; [alertController.view addSubview:view]; [self presentViewController:alertController animated:YES completion:nil]; 这产生了下面的结果。 我有相同的问题,试图获得UIAlertController X,Y宽度和高度属性。 有没有人知道我怎么可以不使用硬编码的数字位于警报控制器的中间这个观点?