uialertcontroller

UIAlertController button function not working

血红的双手。 提交于 2019-12-10 16:25:31
问题 let location = CLLocationCoordinate2D(latitude: 32.075300, longitude: 34.782563) @IBAction func DirectionsTolocationButton(_ sender: Any) { // Create the AlertController and add its actions like button in ActionSheet let ActionSheet = UIAlertController(title: "Please Select A Navigation Service.", message: nil, preferredStyle: .actionSheet) let AppleMapsButton = UIAlertAction(title: "Apple Maps", style: .default) { action -> Void in let destinationName = (self.barNameTemplate ) self

UIAlertController's textfield delegate does not get called

不打扰是莪最后的温柔 提交于 2019-12-10 15:47:58
问题 I have added a UITextField to UIAlertController, but shouldChangeCharactersInRange will get not fired. Why? I set the delegate. let alertController = UIAlertController(title: "", message: "xxx", preferredStyle: .Alert) self.presentViewController(alertController, animated:true, completion:nil) let textField = UITextField() textField.delegate = self alertController.addTextFieldWithConfigurationHandler(nil) and in the same class, the delegate: func textField(textField: UITextField!,

Why does UIAlertController create a retain cycle with self?

耗尽温柔 提交于 2019-12-10 15:36:57
问题 UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"alert" message:nil preferredStyle:UIAlertControllerStyleAlert]; UIAlertAction *action = [UIAlertAction actionWithTitle:@"action" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) { [self doSomething]; }]; [alert addAction:action]; [self presentViewController:alert animated:YES completion:nil]; I understand the cycle . self retains the UIAlertController , UIAlertController retains the

Change title and message font of alert using UIAlertController in Swift

不问归期 提交于 2019-12-10 14:53:59
问题 I am trying to change the title and message font for an alert shown using UIAlertController I am trying to do using an NSAttributedStirng, but it gives compiler error that a NSAttributed string cannot be taken instead of Stirng I tried something similar to this var title_attrs = [NSFontAttributeName : CustomFonts.HELVETICA_NEUE_MEDIUM_16] var msg_attrs = [NSFontAttributeName : CustomFonts.HELVETICA_NEUE_REGULAR_14] var title = NSMutableAttributedString(string:"Done", attributes:title_attrs)

UIAlertController's popover is deformed

倖福魔咒の 提交于 2019-12-10 13:35:18
问题 I'm presenting a list of options to the user using an UIAlertController from a UIToolbar with a preferred style of action sheet. When presented, the popover's arrow is cut off and its corners are rounded with two different radii: The code I'm using to present it is straight from the documentation, as far as I see it: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"" message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; NSArray *actions = @[

UIAlertController custom font doesn't work at iOS

回眸只為那壹抹淺笑 提交于 2019-12-10 12:47:56
问题 UIAlertController custom font doesn't work. The following code is a function ShowActionSheetAsync , show ActionSheet . At this point, I want to change the font of ActionSheet . I have tried several ways, but it didn't work well. Is there good solution? public Task<bool> ShowActionSheetAsync() { var source = new TaskCompletionSource<bool>(); var alert = new UIAlertController { Title = "title" }; alert.AddAction(UIAlertAction.Create( "button1", UIAlertActionStyle.Default, _ => source.SetResult

UIAlertController moves leftBarButtonItem down

南笙酒味 提交于 2019-12-10 12:43:21
问题 I've created a UIAlertController with the preferred style of UIAlertControllerStyleAlert . The alert shows when the leftBarButtonItem is tapped. I created a UIBarButtonItem property called backButton and set the leftBarButtonItem = self.backButton . This is working as designed. I'm not using storyboards. The problem is that the leftBarButtonItem moves down (my guess: about 20pts) when the alert shows. Why is this happening? I know how to show/hide the button so the user can't see that the

Swift Attempt to present UIAlertController whose view is not in the window hierarchy (presented after TWTRShareEmailViewController)

怎甘沉沦 提交于 2019-12-10 12:32:11
问题 I'm using the Twitter login in the signup process of my app. And I'm asking for the user's email. Once I get it, I'd like to present a UIAlertController. Here's my code: func askForTWMail(){ if (Twitter.sharedInstance().session() != nil) { let shareMailVC=TWTRShareEmailViewController(completion: {(mail:String!, error:NSError!) in if (mail != nil) { print("GOT MAIL: \(mail)") self.gotMail() }else{ print("MAIL VC ERROR: \(error)") } }) println("PRESENT MAIL VC") self.presentViewController

How do i display UIAlertController from any NSObject subclass?

喜欢而已 提交于 2019-12-10 10:35:56
问题 I have a legacy codebase I am managing, which needs to display alert messages from all over the place. This is terrible practice and is in need of a refactor, but that isn't going to happen any time soon. With iOS 9 I need the ability to fire & forget an alert view, and have the view display and queuing managed for me. 回答1: To show, UIAlertController , we need object of UIViewController So you can use below way to do that. UIWindow *keyWindow = [[UIApplication sharedApplication]keyWindow];

Add image into UIAlertController in swift

末鹿安然 提交于 2019-12-10 10:07:11
问题 I want to have a simple UIAlertController with image in it. what should I do? let alertMessage = UIAlertController(title: "Service Unavailable", message: "Please retry later", preferredStyle: .Alert) alertMessage.addAction(UIAlertAction(title: "OK", style: .Default, handler: nil)) self.presentViewController(alertMessage, animated: true, completion: nil) 回答1: Try this: let alertMessage = UIAlertController(title: "Service Unavailable", message: "Please retry later", preferredStyle: .Alert) let