uialertcontroller

What is the best way to check if a UIAlertController is already presenting?

巧了我就是萌 提交于 2019-12-28 05:01:04
问题 I have a tableview which, when loaded, each cell could possibly return an NSError, which I have chosen to display in a UIAlertController. Problem is I get this error in the console if multiple errors are returned. Warning: Attempt to present UIAlertController: 0x14e64cb00 on MessagesMasterVC: 0x14e53d800 which is already presenting (null) Ideally, I would ideally like to handle this in my UIAlertController extension method. class func simpleAlertWithMessage(message: String!) ->

How to make data I enter in a UITextField inside a UIAlertController persist through resets in Swift?

喜欢而已 提交于 2019-12-25 16:51:26
问题 I have been trying to integrate a Pinboard bookmarks view (by parsing an RSS Feed and displaying it in a TableView) in my browser app. To get the username and API Token for the feed I have a UIAlertController in the Settings view of my app. The details entered are preserved through the session but if I force quit the app from the multitasking view, The details are deleted. How can I make them stay? This is the code I'm using for the UIAlertController: @IBAction func

How to present UIAlertController when not in a view controller?

假装没事ソ 提交于 2019-12-25 01:48:42
问题 Scenario: The user taps on a button on a view controller. The view controller is the topmost (obviously) in the navigation stack. The tap invokes a utility class method called on another class. A bad thing happens there and I want to display an alert right there before control returns to the view controller. + (void)myUtilityMethod { // do stuff // something bad happened, display an alert. } This was possible with UIAlertView (but perhaps not quite proper). In this case, how do you present a

UIAlertController disappearing since iOS 13

跟風遠走 提交于 2019-12-25 01:25:14
问题 I have the following function that pops up a UIAlert which allows the user to update their Haptic Feedback setting: - (void)requestHapticSetting{ UIWindow *alertWindow = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds]; alertWindow.rootViewController = [[UIViewController alloc] init]; alertWindow.windowLevel = UIWindowLevelAlert + 1; [alertWindow makeKeyAndVisible]; if(isHapticOn){ hapticMessage = @"Haptic feedback is currently\nturned ON.\nPlease update preference."; } else {

Add image to ActionSheet and put it to right

自作多情 提交于 2019-12-24 19:08:15
问题 I want to put the image to the right in an ActionSheet as seen on the AppStore. I know how to add an image and change the titleText style but I am unable to figure out how to change the positions of these two. Third party libraries are not appreciated. Thanks! Screenshot - AppStore 回答1: Updated to swift 4.2 and added images. Go through below link for more info. How to customize UIAlertController with UITableView or is there any default control available like this UI in Pages app? import

Redirect to notification setting directly from iOS app that having support of iOS8+

99封情书 提交于 2019-12-24 12:38:06
问题 My requirement is that - if notification for the app is turned off by user and user opens the app at that time it will give alert for turn on notification for the app and when click on okay button of alert view app will redirect to notification screen where user need to click on switch button only to turn on the notifications. Is it possible in ios8+ ? I want to redirect this screen Thanks 回答1: This code will redirect you to setting of notifications. if ([[UIApplication sharedApplication]

Basic UIAlertController Unable to satisfy constraints

 ̄綄美尐妖づ 提交于 2019-12-24 06:37:13
问题 UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert]; [alertController show]; This code is causing the following error: ...[LayoutConstraints] Unable to simultaneously satisfy constraints. Probably at least one of the constraints in the following list is one you don't want. Try this: (1) look at each constraint and try to figure out which you don't expect; (2) find the code that added the unwanted

Xcode 11 beta 5: UI freezes when adding textFields into UIAlertController

人盡茶涼 提交于 2019-12-24 06:27:28
问题 When I add one or more textField into UIAlertController the app freezes, once I deleted the textFields it works perfectly fine. Xcode 11 beta 5 running on Mojave 10.14.6 @IBAction func addRecipeBtnHandler(_ sender: Any) { let alert = UIAlertController(title: "Add new recipe", message: nil, preferredStyle: .alert) alert.addTextField { textField in textField.placeholder = "title" } alert.addTextField { textField in textField.placeholder = "description" } let action = UIAlertAction(title: "Add",

Xcode 11 beta 5: UI freezes when adding textFields into UIAlertController

我们两清 提交于 2019-12-24 06:26:11
问题 When I add one or more textField into UIAlertController the app freezes, once I deleted the textFields it works perfectly fine. Xcode 11 beta 5 running on Mojave 10.14.6 @IBAction func addRecipeBtnHandler(_ sender: Any) { let alert = UIAlertController(title: "Add new recipe", message: nil, preferredStyle: .alert) alert.addTextField { textField in textField.placeholder = "title" } alert.addTextField { textField in textField.placeholder = "description" } let action = UIAlertAction(title: "Add",

iOS 8 Swift : How to keep the keyboard displayed when the UIAlercontroller is presented modally?

南笙酒味 提交于 2019-12-24 04:20:22
问题 The context is pretty simple, there is a UIViewcontroller with a textfield to enter a phone number. The textfield is in editing mode with keyboard. When the number is entered, the user can tap a button which displays an alert controller. As the alert is presented modally it covers the UIViewcontroller and removes keyboard, the editing is no more enabled. Thus my question, what should be done to keep the keyboard displayed behind the alert? 回答1: This solution worked let rootViewController: