Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Or you inherit your class from UIAlertView and add NSNotification observer for UIApplicationWillResignActiveNotification and when notification occurs call to alertview method <code>dismissWithClickedButtonIndex:</code></p> <p>Example: .h file</p> <pre><code>#import &lt;UIKit/UIKit.h&gt; @interface ADAlertView : UIAlertView @end </code></pre> <p>.m file</p> <pre><code>#import "ADAlertView.h" @implementation ADAlertView - (void) dealloc { [[NSNotificationCenter defaultCenter] removeObserver:self]; } - (id) initWithTitle:(NSString *)title message:(NSString *)message delegate:(id)delegate cancelButtonTitle:(NSString *)cancelButtonTitle otherButtonTitles:(NSString *)otherButtonTitles, ... { self = [super initWithTitle:title message:message delegate:delegate cancelButtonTitle:cancelButtonTitle otherButtonTitles:otherButtonTitles, nil]; if (self) { [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(dismiss:) name:UIApplicationDidEnterBackgroundNotification object:nil]; } return self; } - (void) dismiss:(NSNotification *)notication { [self dismissWithClickedButtonIndex:[self cancelButtonIndex] animated:YES]; } @end </code></pre> <p>With your own class inherited from UIAlertView you are need not to store link to alertview or something else, only one thing that you must do its replace UIAlertView to ADAlertView (or any other class name). Feel free to use this code example (if you are not using ARC, you should add to the dealloc method <code>[super dealloc]</code> after <code>[[NSNotificatioCenter defaultCenter] removeObserver:self]</code>)</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload