UIApplicationã®Notificationsã®ä¸è¦§
ãã©ã¡ã¼ã¿ | 説æ |
---|---|
UIApplicationDidBecomeActiveNotification | ã¢ããªã±ã¼ã·ã§ã³ãã¢ã¯ãã£ãã«ãªã£ãæã«éç¥ãã¢ããªèµ·åæãããã¯è§£é¤æ |
UIApplicationDidChangeStatusBarFrameNotification | ã¹ãã¼ã¿ã¹ãã¼ã®ãµã¤ãºå¤æ´ãçºçããæã«éç¥ãããã¤ã¹ãå転ããæãªã© |
UIApplicationDidChangeStatusBarOrientationNotification | ããã¤ã¹ã®åããå¤ãã£ãå¾ã«éç¥ |
UIApplicationDidEnterBackgroundNotification | ã¢ããªã±ã¼ã·ã§ã³ãããã¯ã°ã©ã¦ã³ãã«å ¥ãæã«éç¥ |
UIApplicationDidFinishLaunchingNotification | ã¢ããªã±ã¼ã·ã§ã³ãèµ·åããç´å¾ã«éç¥ |
UIApplicationDidReceiveMemoryWarningNotification | ã¡ã¢ãªä¸è¶³ã®è¦åçºçæã«éç¥ |
UIApplicationProtectedDataDidBecomeAvailable | ä¿è·ããããã¡ã¤ã«(â»)ã¸ã³ã¼ãããã¢ã¯ã»ã¹ãå¯è½ã«ãªã£ãæã«éç¥ |
UIApplicationProtectedDataWillBecomeUnavailable | ä¿è·ããããã¡ã¤ã«ã¸ã³ã¼ãããã¢ã¯ã»ã¹åºæ¥ãªããªãåã«éç¥ |
UIApplicationSignificantTimeChangeNotification | æéã«å¤§ããªå¤æ´ãæã£ãå ´åã«éç¥ãæ¥ä»ãå¤ãã£ãæãå¤æéã«å¤æ´ãªã© |
UIApplicationWillChangeStatusBarOrientationNotification | ããã¤ã¹ã®åããå¤ããç´åã«éç¥ |
UIApplicationWillChangeStatusBarFrameNotification | ã¹ãã¼ã¿ã¹ãã¼ã®ãµã¤ãºå¤æ´ãããç´åã«éç¥ |
UIApplicationWillEnterForegroundNotification | ã¢ããªã±ã¼ã·ã§ã³ãã¢ã¯ãã£ãã«ãªãç´åã«éç¥ |
UIApplicationWillResignActiveNotification | ã¢ããªã±ã¼ã·ã§ã³ãã¢ã¯ãã£ãã§ç¡ããªãç´åã«éç¥ãéç¥ã¢ã©ã¼ãã表示ãããæãªã©ã«ãéç¥ããã |
UIApplicationWillTerminateNotification | ã¢ããªã±ã¼ã·ã§ã³ãçµäºãããç´åã«éç¥ |
â»ä¿è·ããããã¡ã¤ã«(ä¿è·ãã¡ã¤ã«)ã«ã¤ãã¦ã¯è©³ããã¯ãiOS App Programming Guidãã®ãProtecting Data Using On-Disk Encryptionãã®é ç®ãåç §
éç¥ã®åä¿¡ãéå§
åºæ¬çã«ã¯ä»¥ä¸ã®ããã°ã©ã ã§éç¥ãåããäºãåºæ¥ã¾ãã selector: ã name: ã®å¼æ°ã¯å®éã«ä½¿ç¨ããããã®ã«å¤æ´ãã¦ä¸ããã
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidBecomeActiveNotification:) name:UIApplicationDidBecomeActiveNotification object:nil];
éç¥ãåä¿¡ãåæ¢
1ã¤ã®ã¿åé¤ããæã
[[NSNotificationCenter defaultCenter] removeObserver:self name:UIApplicationDidBecomeActiveNotification object:nil];
ãã¹ã¦ã®éç¥ã®åä¿¡ãåæ¢ããå ´åã
[[NSNotificationCenter defaultCenter] removeObserver: self];
éç¥æã«ãã¼ã¿ãå«ã¾ãã¦ããå ´åã®åå¾æ¹æ³
UIApplicationDidChangeStatusBarFrameNotification/UIApplicationWillChangeStatusBarFrameNotification
å®éã®ä½¿ç¨ä¾ã以ä¸ã®Stack Overflowã®ãã¼ã¸ããã®å¼ç¨ã
iphone - How to position view below green bar during phone call? - Stack Overflow
http://stackoverflow.com/questions/3303997/how-to-position-view-below-green-bar-during-phone-call
- (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameChanged:) name:UIApplicationDidChangeStatusBarFrameNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(statusBarFrameWillChange:) name:UIApplicationWillChangeStatusBarFrameNotification object:nil]; } // ããããå¤æ´ãããç´åã«éç¥ - (void)statusBarFrameWillChange:(NSNotification*)notification { NSValue* rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey]; CGRect newFrame; [rectValue getValue:&newFrame]; NSLog(@"statusBarFrameWillChange: newSize %f, %f", newFrame.size.width, newFrame.size.height); // Move your view here ... } // å¤æ´å¾ã«éç¥ - (void)statusBarFrameChanged:(NSNotification*)notification { NSValue* rectValue = [[notification userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey]; CGRect oldFrame; [rectValue getValue:&oldFrame]; NSLog(@"statusBarFrameChanged: oldSize %f, %f", oldFrame.size.width, oldFrame.size.height); // ... or here, whichever makes the most sense for your app. }
name:UIApplicationDidChangeStatusBarOrientationNotification
以åã®åããéç¥ãããã
- (void)applicationDidChangeStatusBarOrientationNotification:(NSNotification*)notification { NSValue* value = [[notification userInfo] valueForKey:UIApplicationStatusBarOrientationUserInfoKey]; NSInteger orientation; [value getValue:&orientation]; switch (orientation) { case UIInterfaceOrientationPortrait: NSLog(@"UIInterfaceOrientationPortrait"); break; case UIInterfaceOrientationPortraitUpsideDown: NSLog(@"UIInterfaceOrientationPortraitUpsideDown"); break; case UIInterfaceOrientationLandscapeLeft: NSLog(@"UIInterfaceOrientationLandscapeLeft"); break; case UIInterfaceOrientationLandscapeRight: NSLog(@"UIInterfaceOrientationLandscapeRight"); break; default: break; } } - (void)viewDidLoad { [super viewDidLoad]; [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(applicationDidChangeStatusBarOrientationNotification:) name:UIApplicationDidChangeStatusBarOrientationNotification object:nil]; }