Tag: uialertcontroller

UIAlertView / UIAlertController兼容iOS 7和iOS 8

我正在使用Swift写一个应用程序,我需要显示一个警报。 该应用程序必须与iOS 7和iOS 8兼容。 由于UIAlertView已被replace为UIAlertController ,如何检查UIAlertController是否可用而不检查系统版本? 我一直听说苹果build议我们不要检查设备的系统版本,以确定API的可用性。 这是我正在使用的iOS 8,但这在iOS 7上崩溃与“ dyld: Symbol not found: _OBJC_CLASS_$_UIAlertAction ”: let alert = UIAlertController(title: "Error", message: message, preferredStyle: .Alert) let cancelAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil) alert.addAction(cancelAction) presentViewController(alert, animated: true, completion: nil) 如果我使用iOS 8的UIAlertView,我得到这个警告: Warning: Attempt to dismiss from view controller <_UIAlertShimPresentingViewController: 0x7bf72d60> while a presentation or […]

防止解除UIAlertController

我将一个UITextField添加到一个UIAlertController ,它显示为一个AlertView 。 在解除UIAlertController之前,我想validationUITextField的input。 基于validation我想解雇UIAlertController或不。 但是我不知道如何在按下button时阻止UIAlertController的解除操作。 有没有人解决了这个问题或任何想法从哪里开始? 我去了谷歌,但没有运气:/谢谢!

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", […]

在UIAlertController中将图像添加到UIAlertAction

我已经看到了一个UIAlertControllers的屏幕截图,在行的左边有一个图像,但是我没有在文档中看到它。 一个视觉的例子是 下面是我现在用于控制器的代码: UIAlertController * view = [UIAlertController alertControllerWithTitle:@"My Title" message:@"Select you Choice" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { }]; [view addAction:ok]; [self presentViewController:view animated:YES completion:nil];

我将如何在Swift中创build一个UIAlertView?

我一直在努力在Swift中创build一个UIAlertView,但由于某种原因,我无法得到正确的声明,因为我得到这个错误: 无法find接受提供的参数的“init”的重载 这是我写的: let button2Alert: UIAlertView = UIAlertView(title: "Title", message: "message", delegate: self, cancelButtonTitle: "Ok", otherButtonTitles: nil) 然后调用它我正在使用: button2Alert.show() 截至目前它正在崩溃,我似乎无法得到正确的语法。

UIAlertController自定义字体,大小,颜色

我正在使用新的UIAlertController来显示警报。 我有这个代码: // nil titles break alert interface on iOS 8.0, so we'll be using empty strings UIAlertController *alert = [UIAlertController alertControllerWithTitle: title == nil ? @"": title message: message preferredStyle: UIAlertControllerStyleAlert]; UIAlertAction *defaultAction = [UIAlertAction actionWithTitle: cancelButtonTitle style: UIAlertActionStyleCancel handler: nil]; [alert addAction: defaultAction]; UIViewController *rootViewController = [UIApplication sharedApplication].keyWindow.rootViewController; [rootViewController presentViewController:alert animated:YES completion:nil]; 现在我想改变标题和消息的字体,颜色,大小等等。 […]

不在视图控制器中时如何呈现UIAlertController?

场景:用户点击视图控制器上的按钮。 视图控制器是最上面的(显然)在导航堆栈中。 轻敲调用另一个类上调用的实用程序类方法。 在那里发生了一件坏事,我想在控制返回到视图控制器之前在那里显示警报。 + (void)myUtilityMethod { // do stuff // something bad happened, display an alert. } 这是可能的与UIAlertView (但可能不是很合适)。 在这种情况下,如何在myUtilityMethod显示一个myUtilityMethod ?