uialertcontroller

UIAlertView show() behavior for UIAlertController

做~自己de王妃 提交于 2019-11-29 05:05:25
In previous versions of iOS I was able to call show on a UIAlertView in the App Delegate. More specifically, show was called in: func applicationDidBecomeActive(application: UIApplication) Since UIAlertView s disregarded the view hierarchy in most cases, this solution worked no matter where the user was in the app. With the introduction of UIAlertController this problem becomes a little trickier. UIAlertController is now a subclass of UIViewController and needs to be presented just like any other UIViewController. While presenting the UIAlertController from the keyWindow's rootViewController

How to use UITextView in UIAlertController

a 夏天 提交于 2019-11-29 04:40:58
I created a popup alert using alert controller and added two alert actions(ok and cancel) as below. UIAlertController * alert= [UIAlertController alertControllerWithTitle:@"Cycling" message:@"Please enter title and description" preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { [alert dismissViewControllerAnimated:YES completion:nil]; }]; UIAlertAction* cancel = [UIAlertAction actionWithTitle:@"Cancel" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { [alert

UIAlertController if iOS 8, otherwise UIAlertView

点点圈 提交于 2019-11-29 02:53:55
I want to conform to the UIAlertController used in iOS 8 since UIAlertView is now deprecated. Is there a way that I can use this without breaking support for iOS 7? Is there some kind of if condition I can do to check for iOS 8 otherwise do something else for iOS 7 support? Please see the answer of Erwan (below my answer) as I see it is the best. -- You can check the iOS version to use appropriate control like this: if (([[[UIDevice currentDevice] systemVersion] compare:@"8.0" options:NSNumericSearch] == NSOrderedAscending)) { // use UIAlertView } else { // use UIAlertController } I think a

how to add button in UIAlertController In IOS 9

前提是你 提交于 2019-11-29 02:53:49
问题 how we use UIAlertView in iOS 9 and how to add button in UIAlertController UIAlertController * alert=[UIAlertController alertControllerWithTitle:@"Title" message:@"Message"preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction* yesButton = [UIAlertAction actionWithTitle:@"Yes, please" style:UIAlertActionStyleDefault handler:^(UIAlertAction * action) { **//What we write here????????** }]; UIAlertAction* noButton = [UIAlertAction actionWithTitle:@"No, thanks" style:UIAlertActionStyleDefault

KEEP keyboard ON when UIAlertcontroller is presented in Swift?

…衆ロ難τιáo~ 提交于 2019-11-29 02:33:10
问题 When the alert pops up the keyboard is dismissed. I have looked everywhere but did not find solutions to keep the keyboard visible. When alert is presented the textfield seems to resign first responder automatically as the alert is presented modally. How is it possible to keep the keyboard behind this alert which means the textfield still editing even if no interaction will be possible ? 回答1: This solution works for me: let rootViewController: UIViewController = UIApplication

Action Sheet problems in iOS 9

萝らか妹 提交于 2019-11-29 02:23:31
Apple has deprecated the action sheet in iOS 8.3 how do you add an action sheet to my user interface? I realized Apple's documentation isn't very clear on how to create an action sheet with UIAlertController. So after a little playing around I just wanted to share my code, since I couldn't really find anything useful on Stack Exchange about this topic. I had the same problem in my iPhone app, with an UIActionSheet to ask the user if they wanted to take a photo, or pick an image from their gallery. Prior to iOS 9, the following code worked fine: UIActionSheet *actionSheet = [[UIActionSheet

Enable UIAlertAction of UIAlertController only after input

血红的双手。 提交于 2019-11-29 02:00:24
I am using a UIAlertController to present a dialog with a UITextField and one UIAlertAction button labeled "Ok". How do I disable the button until a number of characters (say 5 characters) are input into the UITextField ? Add following property in your header file @property(nonatomic, strong)UIAlertAction *okAction; then copy the following code in your viewDidLoad method of your ViewController self.okAction = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:nil]; self.okAction.enabled = NO; UIAlertController *controller = [UIAlertController alertControllerWithTitle

How to change UIAlertController height?

◇◆丶佛笑我妖孽 提交于 2019-11-28 23:32:18
I created an UIAlertController let alertC = UIAlertController(title: "Title", message: "Message", preferredStyle: UIAlertControllerStyle.Alert) alertC.addTextFieldWithConfigurationHandler(addTextField) alertC.addAction(UIAlertAction(title: "Cancel", style: UIAlertActionStyle.Default, handler: nil)) alertC.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: okButton)) presentViewController(alertC, animated: true, completion: nil) But after that I would like to change the UIAlertController height? How can I do this? Barrett I found you can add constraints before you

How to create uialertcontroller in global swift

自作多情 提交于 2019-11-28 21:57:03
I'm trying to create uialertcontroller in Config.swift file as follow. static func showAlertMessage(titleStr:String, messageStr:String) -> Void { let window : UIWindow? let alert = UIAlertController(title: titleStr, message: messageStr, preferredStyle: UIAlertControllerStyle.Alert); self.window!.presentViewController(alert, animated: true, completion: nil) } problem is I've found problem in self.window!. Type 'Config' has no member 'window' Please let me know how to solve that issue. self.window would mean that there's a window object in this class, and it's not the case. You would need to use

UIAlertController is Crashed (iPad)

柔情痞子 提交于 2019-11-28 20:16:41
I am using Xcode 6 to develop an iOS Application. When I used UIAlertController , it can be worked well on iPhone 6 simulator, but crashes on iPad simulator. My problem while clicking "share", then it could be crashed. How could I solve it? Here is my Code: override func tableView(tableView: UITableView, editActionsForRowAtIndexPath indexPath: NSIndexPath) -> [AnyObject] { var shareAction = UITableViewRowAction(style: UITableViewRowActionStyle.Default, title: "Share", handler: { (action:UITableViewRowAction!, indexPath:NSIndexPath!) -> Void in let shareMenu = UIAlertController(title: nil,