Search code examples
iosobjective-cstatusbaraudio-recordingnsnotificationcenter

How to get notified when red audio-recording status bar shows?


The view of my iOS app moves slightly down when red audio-recording status bar caused by some third party app (like Viber) is showing. This kinda breaks the interface of my app.

Is there any system notification i can subscribe to to get notified when this bar is showing? Can i get the height of this bar?


Solution

  • You need to use notifications when status bar changed.

    Use code below to handle this:

    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view, typically from a nib.
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(change:)
                                                     name:UIApplicationWillChangeStatusBarFrameNotification
                                                   object:nil];
    
    }
    
    - (void)change:(NSNotification *)notificacion {
        NSLog(@"%@", notificacion.userInfo);
    }