Tag: uialertcontroller

为UIAlertAction编写处理程序

我向用户展示一个UIAlertView ,我不知道如何编写处理程序。 这是我的尝试: let alert = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert) alert.addAction(UIAlertAction(title: "Okay", style: UIAlertActionStyle.Default, handler: {self in println("Foo")}) 我在Xcode中遇到了一堆问题。 文档中提到了convenience init(title title: String!, style style: UIAlertActionStyle, handler handler: ((UIAlertAction!) -> Void)!) 现在,整个街区/封闭物都比我头高一点。 任何build议都非常感谢。

有没有办法将UIPickerView添加到Swift中的UIAlertController(Alert或ActionSheet)?

我对swift(以及iOS编程)完全陌生,但是我开始搞乱它(当所有东西都是beta版时,这不是一个好主意:D)。 所以我试图自己弄清楚,但还是一无所获。 甚至试图添加包含select器的子视图没有任何成功。 那么,任何人都可以帮助我吗?

如何更改UIAlertController的背景颜色?

由于UIActionSheet在iOS 8中的奇怪行为,我已经使用UIAction实现了UIAlertController作为button。 我想改变UIAlertController的整个背景。 但我找不到任何方法来做到这一点。 甚至尝试过, actionController.view.backgroundColor = [UIColor blackColor]; 但是没有帮助我。 任何有关这方面的投入都是可观的。 提前致谢。

AlertController不在窗口层次结构中

我刚刚创build了一个ViewController类的单一视图应用程序项目。 我想从位于我自己的类中的函数显示一个UIAlertController。 这是我的class级警报。 class AlertController: UIViewController { func showAlert() { var alert = UIAlertController(title: "abc", message: "def", preferredStyle: .Alert) self.presentViewController(alert, animated: true, completion: nil) } } 这是执行警报的ViewController。 class ViewController: UIViewController { override func viewDidLoad() { super.viewDidLoad() } @IBAction func showAlertButton(sender: AnyObject) { var alert = AlertController() alert.showAlert() } } 这是我得到的,而不是美丽的戒备。 警告:尝试在Sprint1.AlertController上显示UIAlertController:0x797d2d20:0x797cc500其视图不在窗口层次结构中! 我该怎么办?

UIAlertView首先不赞成使用IOS 9

我已经尝试了几种使用UIAlertController而不是UIAlertView的方法。 我尝试了几种方法,但无法使警报操作起作用。 这里是我的代码在IOS 8和IOS 9中正常工作,但显示不赞成使用的标志。 我尝试了下面的优雅build议,但是我不能在这方面使它起作用。 我需要提交我的应用程序,这是最后要解决的问题。 感谢您的任何进一步的build议。 我是一个新手。 #pragma mark – BUTTONS ================================ – (IBAction)showModesAction:(id)sender { NSLog(@"iapMade: %d", iapMade3); // IAP MADE ! =========================================== if (!iapMade3) { //start game here gamePlaysCount++; [[NSUserDefaults standardUserDefaults]setInteger:gamePlaysCount forKey:@"gamePlaysCount"]; NSLog(@"playsCount: %ld", (long)gamePlaysCount); if (gamePlaysCount >= 4) { UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Basic" message: THREE_PLAYS_LIMIT_MESSAGE delegate:self cancelButtonTitle:@"Yes, please" otherButtonTitles:@"No, thanks", […]