uialertcontroller

How to add textField in UIAlertController?

青春壹個敷衍的年華 提交于 2019-11-27 19:59:27
I want to realize a function about changing password,it requires user to input his previous password,and I design it in a alert dialog,I want to click the button "Confirm the modification" then jump to the other view controller for changing password.I have written some code,but I don't know how to write in the next moment. Charmi Gheewala You can add multiple textfields to alert controller and access them with the alert controller's textFields property If the new password is an empty string, present the alert again. Or another way would be to disable the "Confirm" button, enabling it only when

UIAlertController text alignment

ぃ、小莉子 提交于 2019-11-27 19:37:25
Is there a way to change the alignment of the message displayed inside a UIAlertController on iOS 8? I believe accessing the subviews and changing it for the UILabel is not possible anymore. Eduardo I have successfully used the following, for both aligning and styling the text of UIAlertControllers: let paragraphStyle = NSMutableParagraphStyle() paragraphStyle.alignment = NSTextAlignment.Left let messageText = NSMutableAttributedString( string: "The message you want to display", attributes: [ NSParagraphStyleAttributeName: paragraphStyle, NSFontAttributeName : UIFont.preferredFontForTextStyle

UIAlertView show() behavior for UIAlertController

拟墨画扇 提交于 2019-11-27 18:52:42
问题 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

iOS 8 Only Memory Leak with UIAlertController or UIActionSheet

落花浮王杯 提交于 2019-11-27 18:06:36
问题 I'm seeing a memory leak in iOS 8 in simulator when I do the following with UIActionSheet or UIAlertController. UIActionSheet uses UIAlertController in IOS 8 so the issues are related. showCameraAction gets called when a button is pressed. I've removed all of the content from the delegate method and still get the leak in the case shown below. Am I using UIActionSheet in some way that I shouldn't? I would appreciate any help in resolving this issue. The same code has no leaks with IOS 7 (in

Get input value from TextField in iOS alert in Swift

ε祈祈猫儿з 提交于 2019-11-27 17:22:08
I'm trying to make an alert message with input, and then get the value from the input. I've found many good tutorials how to make the input text field. but I can't get the value from the alert. Updated for Swift 3 and above: //1. Create the alert controller. let alert = UIAlertController(title: "Some Title", message: "Enter a text", preferredStyle: .alert) //2. Add the text field. You can configure it however you need. alert.addTextField { (textField) in textField.text = "Some default text" } // 3. Grab the value from the text field, and print it when the user clicks OK. alert.addAction

Action Sheet problems in iOS 9

浪尽此生 提交于 2019-11-27 16:41:55
问题 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. 回答1: 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

Enable UIAlertAction of UIAlertController only after input

有些话、适合烂在心里 提交于 2019-11-27 16:24:32
问题 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 ? 回答1: 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

Warning: Attempt to present <UIAlertController: 0x7facd3946920> on <…> which is already presenting (null)

孤街醉人 提交于 2019-11-27 15:45:52
问题 I have a long press gesture set on a UITableView that presents a UIAlertController containing the cell's text. When the UIAlertController is presented I get this warning: Attempt to present <UIAlertController: 0x7fd57384e8e0> on <TaskAppV2.MainTaskView: 0x7fd571701150> which is already presenting (null) From my understanding, MainTaskView (the UITableView ) is already presenting a view, so it shouldn't present a second view, the UIAlertController. So I tried this solution from a similar

How to change UIAlertController height?

倾然丶 夕夏残阳落幕 提交于 2019-11-27 14:55:27
问题 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

swift UIAlertController with pickerView button action stay up

☆樱花仙子☆ 提交于 2019-11-27 14:49:59
问题 I am new in swift and I am trying to make UIAlertContoller with PickerView but I have problems with the Buttones, Here a photo I am trying to change the constraint of the buttons to stay up. I read a lot of answers here but I did not find any solution Here is my code: func distance(){ let editRadiusAlert = UIAlertController(title: "Choose distance", message: "", preferredStyle: UIAlertControllerStyle.alert) let pickeViewFrame: CGRect = CGRect(x: 0, y: 0, width: 250, height: 300) let