uialertcontroller

Updating UILabel from UIAlertAction handler not working in Swift 4

妖精的绣舞 提交于 2019-12-11 15:17:35
问题 I have a subclass of UITableView in my iOS app (Swift 4, XCode 9). This table has one row and I want it to display an alert when it's clicked, get some input from the user, and then update a label ( lblUserFromPrefs ) in the table when the user clicks "OK" in the alert. Currently everything works fine except the label doesn't get updated. Here is the relevant code from my UITableView subclass: override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { print(

How to implement UIAlertcontroller as PopOver(with arrow direction up) in a UIBarbutton

一笑奈何 提交于 2019-12-11 14:24:22
问题 I know that this is old school question - but I did searched the web and found solutions to be deprecated. How would I implement a UIAlertcontroller as popOver(with arrow direction up) in a barButton . Here's the code: - (IBAction)eventSortingAction:(UIBarButtonItem *)sender { UIAlertController * view= [UIAlertController alertControllerWithTitle:@"My Title" message:@"Select you Choice" preferredStyle:UIAlertControllerStyleActionSheet]; UIAlertAction* ok = [UIAlertAction actionWithTitle:@"OK"

Custom TextField in UIAlertController [duplicate]

瘦欲@ 提交于 2019-12-11 14:19:05
问题 This question already has answers here : How to add textField in UIAlertController? (3 answers) Closed 2 years ago . I could add a textfield in UIAlertController using UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"message" preferredStyle:UIAlertControllerStyleAlert]; [alertController addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { }]; Is there any possibility to add a custom textfield inside an alert controller?

UIAlertController does not show immediately

坚强是说给别人听的谎言 提交于 2019-12-11 12:17:32
问题 Xcode version: 7.2.1, iOS version: 9.1+ I am trying to display a UIAlertController alert message on the iPad that shows a "Loading...Please Wait" message without any buttons on it. I present the UIAlertController before starting a long operation, and then after the long operation, I dismiss the UIAlertController. However, what is happening is the UIAlertController DOES NOT show up immediately. It only flashes up briefly AFTER the longer operation is completed, and then it is dismissed.

UIAlertcontroller as an action in Swift

与世无争的帅哥 提交于 2019-12-11 11:14:09
问题 So I want to have an alert popping up telling me a message, then I want it to wait for me until i press OK and then it will continue with the function. For example. @IBAction Alert() { let alertController = UIAlertController(title: title, message: message, preferredStyle: UIAlertControllerStyle.Alert) alertController.addAction(UIAlertAction(title: "OK", style: UIAlertActionStyle.Default, handler: nil)) self.presentViewController(alertController, animated: true, completion: nil) } The problem

Swift: Show UIAlertController in didReceiveLocalNotification method

不羁的心 提交于 2019-12-11 09:58:35
问题 I want to show alert when notification is fired while app is running, here is tutorial which i used for local notifications. In tutorial, it uses UIAlertView to show alert and it works, here is code: func application(application: UIApplication, didReceiveLocalNotification notification: UILocalNotification) { // Point for handling the local notification when the app is open. // Showing reminder details in an alertview UIAlertView(title: notification.alertTitle, message: notification.alertBody,

Centering an image in UIAlertAction in UIAlertController

别等时光非礼了梦想. 提交于 2019-12-11 09:41:47
问题 I am currently adding images to UIAlertAction with the following code (Swift). purpleAction.setValue(pCircle, forKey: "image") I want to centre the image in the UIAlertAction if possible. Currently the UIAlertAction has a title that is in the centre, and the image appears on the left hand side. 回答1: You cannot change the frame of image, you need to build custom alertView for your issue. 回答2: You can actually hack this with imageWithAlignmentRectInsets: UIAlertController *ac =

UIAlertController memory leak/issues - Swift

半城伤御伤魂 提交于 2019-12-11 09:15:27
问题 Instruments shows a memory leak from simply opening and closing the alert controller. @IBAction func delBtnAc(sender: AnyObject) { let deleteAlert = UIAlertController(title: "Delete Image?", message: "", preferredStyle: .Alert) let cancelIt = UIAlertAction(title: "Cancel", style: .Cancel, handler: nil) deleteAlert.addAction(cancelIt) presentViewController(deleteAlert, animated: true, completion: nil) } I have reduced the alert to only a cancel button for testing. Edited: Removed deleteAlert

Show UIAlertController from a common utility class

两盒软妹~` 提交于 2019-12-11 06:06:57
问题 I am working on a project that uses UIAlertView , now the problem is I have to replace all of the UIAlertView's with UIAlertController's and there are around 1250 of them in the code. I am planning to uses the existing Utility class to create a function that does this, following is what I am planning to do: +(void)showAlert:(NSString *)title errorMessage:(NSString *)msg { UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:msg preferredStyle

How can I add a url to an alert?

半世苍凉 提交于 2019-12-11 05:48:33
问题 Is there a method to add an url for users looking for additional information? My alert looks like this let alert = UIAlertController(title: "Alert details", message: "For more detailed information, click the link below", preferredStyle: UIAlertControllerStyle.Alert) // add url here let okayAction = UIAlertAction(title: "Ok", style: .Default) { (action) in print(action) } alert.addAction(okayAction) The idea is to redirect them to a webpage and close the UIAlertController in the app 回答1: You