How to detect call-in-progress status bar in landscape?

523 views Asked by At

My app needs to detect the presence or absence of the call-in-progress status bar (green). In portrait orientation, the status bar becomes 40px tall when a call is in progress, so a change in the call state triggers the willChangeStatusBarFrame and didChangeStatusBarFrame methods in my app delegate.

The problem is that this only works in portrait; in landscape orientation, the status bar is 20px tall regardless of the call state, so the status bar frame change methods aren't called at all when the call state toggles.

I don't want to get into the telephony API in order to detect an actual ongoing call (although I guess I may be forced to do this) as a proxy for detecting the status bar state, as this won't work in the simulator.

Is there any way to detect this status bar state without relying on the status bar frame change methods?

2

There are 2 answers

0
liamnichols On

I would suggest that you use the Core Telephony Framework to detect if a call is in progress as checking for status bar frame changes seems very unreliable (i.e what if the frame changes in a new version of iOS? what about personal hotspot? what if you launch the app while already in call?) like you have already discovered.

Your layout on the other hand shouldn't have to worry about this frame change notification. You should be able to reposition your subviews when viewDidLayoutSubviews is called on your view controller as it will notify you about bounds changes to self.view.

Hope that helps.

0
Brian Cannard On

You could use heuristics: if status bar before rotation from portrait had large height.