Tag: uialertcontroller

UIPopover如何使用这样的button制作popover?

我想知道如何创build一个像这样的buttonpopover。 回答: UIActionSheet * actionSheet = [[UIActionSheet alloc] initWithTitle: nil delegate: self cancelButtonTitle: nil destructiveButtonTitle: nil otherButtonTitles: @"Take Photo", @"Choose Existing Photo", nil]; [actionSheet showFromRect: button.frame inView: button.superview animated: YES]; 你的委托对象类中的其他地方… -(void)actionSheet:(UIActionSheet *)actionSheet clickedButtonAtIndex:(NSInteger)buttonIndex { if (buttonIndex == 0) { // take photo… } else if (buttonIndex == 1) { // choose existing photo… } […]

检查UIAlertController TextField是否启用button

我有一个AlertController与文本字段和两个button:取消和保存。 这是代码: @IBAction func addTherapy(sender: AnyObject) { let addAlertView = UIAlertController(title: "New Prescription", message: "Insert a name for this prescription", preferredStyle: UIAlertControllerStyle.Alert) addAlertView.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) addAlertView.addAction(UIAlertAction(title: "Save", style: UIAlertActionStyle.Default, handler: nil)) addAlertView.addTextFieldWithConfigurationHandler({textField in textField.placeholder = "Title"}) self.presentViewController(addAlertView, animated: true, completion: nil) } 我想要做的是实现一个文本框检查当禁用保存button,当文本框是空的就像图片应用程序的iOS,当你想创build一个NewAlbum。 请有人能解释我该怎么做?

不能完全解雇我以前的alertcontroller

我试图使用一个单一的警报控制器,其中包括多个警报显示function和一个解雇function。但我在我的控制台有这个警告 ,我的其他警报不显示。我想知道为什么?和解决scheme。 这是我的警报控制器 import UIKit class MyAlertViewController: UIViewController { var myAlertController : UIAlertController! override func viewDidLoad() { super.viewDidLoad() } override func didReceiveMemoryWarning() { super.didReceiveMemoryWarning() // Dispose of any resources that can be recreated. } func displayLoadingAlert(viewController: UIViewController?) -> UIAlertController { var controllerToPresent = viewController if controllerToPresent == nil { controllerToPresent = self } //create an […]

防止UIAlertControllerclosures

我想阻止UIAlertController被解雇。 我有一个UIAlertAction ,只是将一个string追加到UIAlertTextField中,但是,一旦点击它,视图控制器[不希望的]。 我试着添加一个NSNotification与不希望的结果。 UIAlertAction *pasteMessage = [UIAlertAction actionWithTitle:@"Paste Message" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { UITextField *textField = alertC.textFields.firstObject; textField.text = [textField.text stringByAppendingString:[NSString stringWithFormat:@"%@", copiedString]]; }]; 我也试过设置no来通过pasteMessage: [alertC canPerformAction:@selector(dismissViewControllerAnimated:completion:) withSender:pasteMessage]; -(void)dismissViewControllerAnimated:(BOOL)flag completion:(void (^)(void))completion { UIAlertController *alertController = (UIAlertController *)self.presentedViewController; UIAlertAction *paste = alertController.actions.firstObject; if (paste) { flag = NO; } else { flag = YES; } […]

如何从Appdelegate显示UIAlertController

我正在iOS应用上使用PushNotification。 我想在应用程序收到通知时显示一个UIalertcontroller。 我在AppDelegate下面试试这个代码: [self.window.rootViewController presentViewController:alert animated:YES completion:nil]; 但UIAlertcontroller显示在根视图(第一屏幕)和其他uiviewcontroller我得到警告或应用程序崩溃。

在UIAlertController之外轻触如何解除UIAlertController?

在UIAlertController之外轻触如何解除UIAlertController ? 我可以添加UIAlertAction的UIAlertActionStyleCancel来closuresUIAlertController 。 但是我想添加一个函数,当用户点击UIAlertController , UIAlertController会解散。 怎么做? 谢谢。

UIAlertController文本alignment

有没有办法改变在iOS 8的UIAlertController内显示消息的alignment方式? 我相信访问子视图并更改为UILabel是不可能的了。

如何在UIAlertController的中心显示活动指标?

我目前有一个UIAlertController屏幕上显示。 警报的视图应该只在警报的中心显示2个元素,一个标题和一个UIActivityIndicatorView 。 以下是显示警报及其元素的function。 func displaySignUpPendingAlert() -> UIAlertController { //Create the UIAlertController let pending = UIAlertController(title: "Creating New User", message: nil, preferredStyle: .Alert) //Create the activity indicator to display in it. let indicator = UIActivityIndicatorView(frame: CGRectMake(pending.view.frame.width / 2.0, pending.view.frame.height / 2.0, 20.0, 20.0)) indicator.center = CGPointMake(pending.view.frame.width / 2.0, pending.view.frame.height / 2.0) //Add the activity indicator […]

如何在ios 8的alertview中添加文本input?

我想在ios 8的警报视图中添加文本input。我知道这是使用UIAlertController完成,但没有任何想法。 怎么做 ?

在iOS8中显示与UIActionSheet UIPickerView不起作用

在iOS8中显示与UIActionSheet UIPickerView不起作用 该代码适用于iOS7 ,但它不适用于iOS8 。 我确定这是因为UIActionSheet在iOS8中被弃用,Applebuild议使用UIAlertController 。 但是,如何在iOS8中做到这一点 ? 我应该使用UIAlertController ? iOS7 : iOS8 : 编辑: 我的GitHub项目解决了这个问题。