uialertaction

How can I perform the handler of a UIAlertAction?

房东的猫 提交于 2019-12-05 15:13:09
I'm trying to write a helper class to allow our app to support both UIAlertAction and UIAlertView . However, when writing the alertView:clickedButtonAtIndex: method for the UIAlertViewDelegate , I came across this issue: I see no way to execute the code in the handler block of a UIAlertAction . I'm trying to do this by keeping an array of UIAlertAction s in a property called handlers @property (nonatomic, strong) NSArray *handlers; and then implement a delegate like such: - (void) alertView:(UIAlertView *)alertView clickedButtonAtIndex:(NSInteger)buttonIndex { UIAlertAction *action = self

Select text in UIAlertController's text field

 ̄綄美尐妖づ 提交于 2019-12-05 03:52:23
I need the text of the text field to be selected right after the UIAlertController is presented. However, the way I select text in a standard UITextField doesn't work here. This is what I tried, but I can't seem to get it work. let ac = UIAlertController(title: "Rename", message: nil, preferredStyle: .Alert) ac.addTextFieldWithConfigurationHandler({ [] (textField: UITextField) in textField.selectedTextRange = textField.textRangeFromPosition(textField.beginningOfDocument, toPosition: textField.endOfDocument) textField.text = "filename.dat" }) ac.addAction(UIAlertAction(title: "CANCEL", style:

UIAlertAction handler running after delay

爱⌒轻易说出口 提交于 2019-12-03 15:37:31
问题 I'm trying to change my UIAlertViews to UIAlertControllers. I set up this action for it: UIAlertAction *undoStopAction = [UIAlertAction actionWithTitle:@"Undo Stop" style:UIAlertActionStyleDefault handler:^(UIAlertAction *action) { [self undoStop]; }]; But, the handler doesn't run until about a second after the action is tapped. Is there any way to speed this up? 回答1: The short delay is normal for Alert View (less than a second though). If this is not convenient for you, you can

Should self be captured as strong in a UIAlertAction's handler?

早过忘川 提交于 2019-12-02 16:34:11
When writing the handler closure of a UIAlertAction , should the reference to self be strong (the default), weak , or unowned ? There have been posts relevant to this topic ( 1 , 2 , 3 , 4 ) but I honestly don't see how they help in this case. Let's focus on this typical code: func tappedQuitButton() { let alert = UIAlertController(title: "Confirm quit", message: nil, preferredStyle: .ActionSheet) let quitAction = UIAlertAction(title: "Quit", style: .Default) { (action) in self.dismissViewControllerAnimated(true, completion: nil) } alert.addAction(quitAction) let cancelAction = UIAlertAction

How to present UIAlertController from SKScene

半世苍凉 提交于 2019-12-02 01:01:54
I'm working in Spritekit and I'm trying to present a UIAlertController from my SKScene, but I am having trouble doing it. I've watched several tutorials but none of the UIAlertController tutorials have been specific to Spritekit. I keep seeing this code below, but it has not been effective since SKScene is not a UIViewController. [self presentViewController:self animated:YES completion:nil]; I have the rest of the relative code below. Can anybody please help me present my UIAlerController on my SKScene. UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"You Lose!" message

Cropped characters - iOS11 - Alert Dialog

拟墨画扇 提交于 2019-12-01 14:24:29
Cropped characters - iOS11 - Alert Dialog. How to fix it? [ func settingsButtonPressed() { let alert = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) let closeAction = UIAlertAction(title: "Anuluj", style: .cancel) { (action) in //do nothing } alert.addAction(closeAction) let restorePurchases = UIAlertAction(title: "Przywróć zakupy", style: .default) { (action) in self.restorePurchases() } alert.addAction(restorePurchases) let refreshCatalogs = UIAlertAction(title: "Odśwież", style: .default) { (action) in self.collectionView.reloadData() } alert.addAction

How to change font size and color of UIAlertAction in UIAlertController

泪湿孤枕 提交于 2019-12-01 00:00:47
In the image above how to change the font size and color of "Done", "Some Other action"? and how to change the font size and color of "title", and "message"? Thank you. jimrice This is from another stack overflow post but seems to work fine. Post found here. UIAlertController *alertVC = [UIAlertController alertControllerWithTitle:@"Dont care what goes here, since we're about to change below" message:@"" preferredStyle:UIAlertControllerStyleActionSheet]; NSMutableAttributedString *hogan = [[NSMutableAttributedString alloc] initWithString:@"Presenting the great... Hulk Hogan!"]; [hogan

Send Local Notifications while App is running in the background Swift 2.0

假如想象 提交于 2019-11-30 14:11:27
I am trying to send the user a 'Push Notification style' Alert when the user minimizes the app (by clicking on the iPhone's Home Button or by locking the phone as well). My app continuously parses an XML file (every 10 seconds) and I want the app to continue running so that it sends the user a Local Notification once some condition has been met in my program, even after the user has minimized the app or locked their phone. I've bounced around from tutorials and everyone seems to 'schedule' a Notification, but this isn't going to work for me because my Notification isn't time-based, rather it's

UIAlertAction Button Text Alignment Left

纵饮孤独 提交于 2019-11-30 07:43:53
I want to align UIAlertAction text alignment to Left and add the icon as in image shown. I spent lot of time on google to get the solution but not found the right answer. Every body post for the alert title not for the alert action title. Please suggest me the right way for swift . Thanks!! Niraj Solanki You can do that with bellow example code. Easy and Simple. Swift 4 let actionSheetAlertController: UIAlertController = UIAlertController(title: nil, message: nil, preferredStyle: .actionSheet) let cancelActionButton = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)

Send Local Notifications while App is running in the background Swift 2.0

纵饮孤独 提交于 2019-11-29 21:12:39
问题 I am trying to send the user a 'Push Notification style' Alert when the user minimizes the app (by clicking on the iPhone's Home Button or by locking the phone as well). My app continuously parses an XML file (every 10 seconds) and I want the app to continue running so that it sends the user a Local Notification once some condition has been met in my program, even after the user has minimized the app or locked their phone. I've bounced around from tutorials and everyone seems to 'schedule' a