uialertcontroller

How to disable UIAlertAction depending on UITextField in UIAlertController?

末鹿安然 提交于 2020-01-02 04:45:08
问题 I'm using a UIAlertController to present the user with a dialog to enter a 5 digit CRN . I want the Add button to be disabled until there are 5 and only 5 digit in the UITextField . Here's what the UI looks like : Here's the properties setup for the UIAlertController : var alertController: UIAlertController! var addAlertAction: UIAlertAction! { return UIAlertAction(title: "Add", style: .default) } Here's how I'm initializing them in the viewDidLoad method : self.alertController =

dismiss UIAlertController presented by a modal view controller

孤街醉人 提交于 2020-01-02 03:00:07
问题 I seem to be running into a problem similar to one in an unresolved posted question: UIAlertController dismissing his presentingViewController I am presenting a modal view controller on top of a normal UIViewController. Then I'm popping up an alert on that modal view controller. When I push "ok" to dismiss the alert (generated with the code below), the modal view controller is also dismissed. UIAlertAction *ok = [UIAlertAction actionWithTitle:@"OK" style:UIAlertActionStyleDefault handler:^

How to call presentViewController from inside class

南笙酒味 提交于 2020-01-01 18:59:10
问题 Inside my completion handler I am trying to return the http response code much like alert in JS. Once I get this sorted I hope to improve my if statement to identify a connection problem to the end user. I was looking at this article. http://www.ioscreator.com/tutorials/display-an-alert-view-in-ios8-with-swift I have also seen this answer Simple App Delegate method to show an UIAlertController (in Swift) but I get a similar method about the window not being named. My code without all the

iOS 8 broke UIPickerView in UIActionSheet

烂漫一生 提交于 2020-01-01 12:11:04
问题 I was presenting a picker in UIActionSheet very simply up until iOS 8. Now, it seems they have broken that capability with the latest update. It was never supported and the practice was discouraged in the docs all along. Presumably the entire UIActionSheet capability is deprecated and will not be supported going forward. The documentation says to use UIAlertController instead. I have tried switching to the UIAlertController and actually found what I initially expected would be a nicer

UIAlert in Swift that automatically disappears?

一曲冷凌霜 提交于 2020-01-01 11:47:12
问题 I have the following code: /// Creates Alerts on screen for user. func notifyUser(title: String, message: String) -> Void { let alert = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) let cancelAction = UIAlertAction(title: "OK", style: .Cancel, handler: nil) alert.addAction(cancelAction) UIApplication.sharedApplication().keyWindow?.rootViewController!.presentViewController(alert, animated: true, completion: nil) } Which shows the following

Where to find a clear explanation about swift alert (UIAlertController)?

偶尔善良 提交于 2019-12-31 08:47:27
问题 Couldn't find a clear and informative explanation for this. 回答1: After searching a while on a subject I didn't find a clear explanation , even in it's class reference UIAlertController Reference It is ok, but not clear enough for me. So after collecting some peaces I decided to make my own explanation (Hope it helps) So here it goes: UIAlertView is deprecated as pointed out : UIAlertView in Swift UIAlertController should be used in iOS8+ so to create one first we need to instantiate it, the

Where to find a clear explanation about swift alert (UIAlertController)?

南楼画角 提交于 2019-12-31 08:47:26
问题 Couldn't find a clear and informative explanation for this. 回答1: After searching a while on a subject I didn't find a clear explanation , even in it's class reference UIAlertController Reference It is ok, but not clear enough for me. So after collecting some peaces I decided to make my own explanation (Hope it helps) So here it goes: UIAlertView is deprecated as pointed out : UIAlertView in Swift UIAlertController should be used in iOS8+ so to create one first we need to instantiate it, the

Subclassing UIAlertController

大城市里の小女人 提交于 2019-12-29 08:32:10
问题 With pre-iOS 8 we had to use the UIAlertView and UIActionSheet Which we weren't allowed to mess with the view hierarchy or subclass on either them. UIAlertView Documentation The UIAlertView class is intended to be used as-is and does not support subclassing. The view hierarchy for this class is private and must not be modified. UIActionSheet Documentation UIActionSheet is not designed to be subclassed, nor should you add views to its hierarchy. If you need to present a sheet with more

How can i customize UIAlertAction in UIAlertController for iOS8?

房东的猫 提交于 2019-12-29 06:54:11
问题 I need to add image in Action sheet item using UIAlertController . I add using: UIImage *image = [UIImage imageNamed:@"icon.png"]; [alertAction setValue:image forKey:@"image"]; And results as: The problem is that: I need the image & text to be centrally aligned and resize the height of Cancel button How can i do that, please share some code. Thanks! 回答1: Well, here is the Runtime Header file for UIAlertAction . You can neither change the frame of image nor you can change the height of Cancel

How to add text input in alertview of ios 8?

你说的曾经没有我的故事 提交于 2019-12-28 08:04:10
问题 I want to add text input in alert-view of ios 8. I know it was done using UIAlertController but not have any idea. How to do it ? 回答1: Screenshot Code UIAlertController * alertController = [UIAlertController alertControllerWithTitle: @"Login" message: @"Input username and password" preferredStyle:UIAlertControllerStyleAlert]; [alertController addTextFieldWithConfigurationHandler:^(UITextField *textField) { textField.placeholder = @"name"; textField.textColor = [UIColor blueColor]; textField