uialertcontroller

Warning: Presenting view controllers on detached view controllers is discouraged

依然范特西╮ 提交于 2019-12-04 13:59:37
My situation with this is different than every other example I have been able to find on here. I have a tab based app. On one of the tabs a user is able to press a button that downloads several files from a web server all at once. I make use of NSOperation to perform each of these downloads so that I can utilize the built in dependencies. The downloads are all occurring on a background thread so the app remains responsive. When the final download is complete I put an alertController on screen letting the user know that they are complete. If the user has selected a different tab when the alert

UIAlert in Swift that automatically disappears?

Deadly 提交于 2019-12-04 12:39:31
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 Alert: I would prefer the Alert to appear for maybe 1-2 seconds and auto dismiss without having to click ok

UIAlertController Action Sheet without Blurry View Effect

时光毁灭记忆、已成空白 提交于 2019-12-04 11:54:54
I'm using UIAlertController for some actions. But I'm not a big fan of the Blurry View Effect in the actions group view (see screenshot below). I'm trying to remove this blurry effect. I made some research online, and I couldn't find any API in UIAlertController that allows to remove this blurry effect. Also, according to their apple doc here : The UIAlertController 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. I see that Instagram also removes this blurry view effect : The only way I could find to

Alternative to UIAlertView for iOS 9?

不打扰是莪最后的温柔 提交于 2019-12-04 10:11:58
问题 UAlertView is deprecated in iOS 9 and later. What would be an alternative? UIAlertView *new = [[UIAlertView alloc] initWithTitle:@"Success" message:@"Your InApp Purchases were successfully restored" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil]; [new show]; 回答1: You can use this code to replace an alert view: UIAlertController *alertController = [UIAlertController alertControllerWithTitle:@"Title" message:@"Message" preferredStyle:UIAlertControllerStyleAlert]; [alertController

UIAlertController's actionSheet gives constraint error on iOS 12.2 / 12.3 [duplicate]

纵然是瞬间 提交于 2019-12-04 07:32:53
问题 This question already has answers here : Swift default AlertViewController breaking constraints (2 answers) Closed 6 months ago . On iOS 12.2. while using UIAlertController's actionSheet Xcode, gives constraint error anyone having this problem This same code runs on iOS 12.1 with no error I have tested this code on Xcode 10.2 and 10.1 class ViewController: UIViewController { let Click : UIButton = { let button = UIButton(type: UIButton.ButtonType.system) button

UIAlertController textfield width is way smaller than usual

牧云@^-^@ 提交于 2019-12-04 06:09:35
So I have a UIAlertController with a UITextField added for an input but for some reason the textfield appears to be much smaller than it's supposed to be. Any idea why? Here is the Screenshot Here is the Code UIAlertController *alert = [UIAlertController alertControllerWithTitle:@"This is title" message:@"This is message" preferredStyle:UIAlertControllerStyleAlert]; [alert addTextFieldWithConfigurationHandler:^(UITextField * _Nonnull textField) { textField.keyboardType = UIKeyboardTypeNumberPad; textField.placeholder = @"I am a placeholder"; }]; UIAlertAction *okAction = [UIAlertAction

How to rotate UIAlertController in Swift

故事扮演 提交于 2019-12-04 05:47:42
I have a working UIAlertController , but I want to rotate the alert.view by 90 degrees left. How can I do it? My code is here below: let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .Alert) alert.addAction(UIAlertAction(title: "Okay", style: .Default){(action)->() in }) presentViewController(alert, animated: true) {} I tried to add: alert.view.transform = CGAffineTransformMakeRotation(CGFloat(M_PI_2)) but it doesn't work. Thank you ! With this code: let alert = UIAlertController(title: "", message: "Message Sample", preferredStyle: .Alert) alert.addAction

How do I put a UIActivityIndicatorView in a UIAlertController?

纵饮孤独 提交于 2019-12-03 21:19:47
问题 We're moving away from MBProgressHUD because it's too glitchy in our app, and doesn't have features such as blocking user input or providing a Cancel button. So, I've attempted to implement Swipesight's How to display activity indicator in center of UIAlertController?, and I ran into improper positioning of the indicator: It is green because our app's tint is green. As you can see, it's not in the white rectangle part of the controller, but the grey background. This uses something similar to

Navigate to ViewController from UIAlertController button click

独自空忆成欢 提交于 2019-12-03 21:11:52
I am quite new to Swift development and I tried referring to the Swift UIAlertController API but couldn't figure out how to navigate to another UIViewController after clicking a button on the UIAlertController. I would appreciate any pointers, help or a solution to this problem. My code snippet is given below - @IBAction func showAlert() { let alertController = UIAlertController(title: "Disclaimer", message: "Disclaimer Text Here", preferredStyle: .Alert) let declineAction = UIAlertAction(title: "Decline", style: .Cancel, handler: nil) alertController.addAction(declineAction) let acceptAction

Is it possible to rotate UIAlertController (and Alert) in landscape orientation?

空扰寡人 提交于 2019-12-03 17:01:52
I am editing an app where I added a new UIViewController to configure a multiplayer game in one layout. I have added two buttons for each player (top button, bot button). Each button generates an alert at the screen (remember it is in landscape orientation ) but the problem is, player 2 do not see the alert rotated, I mean, the alert is supposed to be shown in his orientation, in front of me. As there any way to do this? I want to rotate an Alert for the player 2 will not see the information of the alert turned. Here the alert code I have: @IBAction func ShowAlert(){ let message = "Test" let