Check if a UIAlertView is showing

Why not just check the visible property, maintained by the UIAlertView class? if (_alert) //alert is a retained property { self.alert = [[[UIAlertView alloc] initWithTitle:@”Your Title” message:@”Your message” delegate:self cancelButtonTitle:@”Cancel” otherButtonTitles:@”OK”] autorelease]; } if (!_alert.visible) { [_alert show]; }

UIAlertController showing with delay

I was having the same issue with a UIAlertController presented by selecting a row from a UITableView. The first time everything worked fine, and then when the user triggered the alert again there was a few seconds delay before the alert was actually presented. As a workaround I used GCD: dispatch_async(dispatch_get_main_queue(), ^{ [self presentViewController:AlertView animated:YES … Read more

EXC_BAD_ACCESS code 2 on UIAlertView in iOS6

I’ve got it. I have the same problem, in my case it seems that the method is thrown from background now (now in ios7, in ios6 UIAlertView was automatically put into the main-thread as @nodepond says -thanks!-).. try to assure that the method is shown from main thread: [alertView performSelectorOnMainThread:@selector(show) withObject:nil waitUntilDone:YES]; Good luck!

UIAlertController is moved to buggy position at top of screen when it calls `presentViewController:`

I encountered a situation where sometimes a modal view would present itself on top of a an alert (silly situation, I know), and the UIAlertController could appear in the top left (like the 2nd screenshot of the original question), and I found a one-liner solution that seems to work. For the controller that’s about to … Read more

How to add an action to a UIAlertView button using Swift iOS

The Swifty way is to use the new UIAlertController and closures: // Create the alert controller let alertController = UIAlertController(title: “Title”, message: “Message”, preferredStyle: .Alert) // Create the actions let okAction = UIAlertAction(title: “OK”, style: UIAlertActionStyle.Default) { UIAlertAction in NSLog(“OK Pressed”) } let cancelAction = UIAlertAction(title: “Cancel”, style: UIAlertActionStyle.Cancel) { UIAlertAction in NSLog(“Cancel Pressed”) } … Read more

NSLocalizedString only retrieves the key, not the value in Localizable.strings (IOS)

In my case it was because I had mistakenly named the file “Localization.strings” and hadn’t noticed (it has to be named Localizable.strings). As explained previously the symptom is because the compiler cannot find the string. Otherwise the cause could be any number of things but usually it’s a missing semi colon or quotation mark. These … Read more

AlertController is not in the window hierarchy

If you’re instancing your UIAlertController from a modal controller, you need to do it in viewDidAppear, not in viewDidLoad or you’ll get an error. Here’s my code (Swift 4): override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(animated) let alertController = UIAlertController(title: “Foo”, message: “Bar”, preferredStyle: .alert) alertController.addAction(UIAlertAction(title: “OK”, style: .cancel, handler: nil)) present(alertController, animated: true, completion: … Read more

UIAlertView/UIAlertController iOS 7 and iOS 8 compatibility

The detection pattern is identical to the Objective-C style. You need to detect whether the current active runtime has the ability to instantiate this class if objc_getClass(“UIAlertController”) != nil { println(“UIAlertController can be instantiated”) //make and use a UIAlertController } else { println(“UIAlertController can NOT be instantiated”) //make and use a UIAlertView } Don’t try … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)