Notifications for registered observers of UIApplicationWillChangeStatusBarFrameNotification don't receive the notification until after [[UIApplication sharedApplication] statusBarFrame] has been updated to the new status bar frame.
| Originator: | cbowns | ||
| Number: | rdar://12560025 | Date Originated: | 23-Oct-2012 |
| Status: | Open | Resolved: | |
| Product: | iOS | Product Version: | iOS 7.0 |
| Classification: | Serious Bug | Reproducible: | Always |
This means that it's not possible to calculate the status bar frame change by only comparing the notification's userInfo UIApplicationStatusBarFrameUserInfoKey key to [[UIApplication sharedApplication] statusBarFrame]. One must instead cache the current status bar frame at view controller init or viewDidLoad: or some other point in time.
---
(A sample project is attached, and also uploaded at http://cl.ly/323K280K1T2p)
Steps to reproduce: (using the attached sample project)
1. Launch the application in the iPhone Simulator with a single-height status bar.
2. Select "Hardware: Toggle In-Call Status Bar".
3. In Xcode, Select "View: Debug Area: Activate Console".
Results:
Expected:
- The console should print:
"statusBarWillChange: the status bar is about to be 20 points taller"
and current status bar frame should be: "{{0, 0}, {320, 20}}", since we were launched with a single height status bar and this is the UIApplication *WillChange* StatusBarFrameNotification.
(Next status bar frame should be: "{{0, 0}, {320, 40}}", since the status bar was normal height, and is now double height.)
Actual:
The console prints:
"statusBarWillChange: the status bar is about to be 0 points taller"
and the current status bar frame is 40 points tall: "{{0, 0}, {320, 40}}".
Regression:
Unknown. This bug exists in at least iOS 4.3. 5.0 and 6.0 in the Simulator, and on the device in at least iOS 6.0 (I don't have older devices to test on.)
Notes:
UIApplication*Did*ChangeStatusBarFrameNotification does not suffer from this bug: since [[UIApplication sharedApplication] statusBarFrame] returns the current status bar frame, and the notification userInfo object contains the old status bar height, calculating the status bar height change is very simple:
CGRect currentStatusBarFrame = [[UIApplication sharedApplication] statusBarFrame];
CGRect oldStatusBarFrame = [[[note userInfo] valueForKey:UIApplicationStatusBarFrameUserInfoKey] CGRectValue];
CGFloat statusBarHeightDifference = currentStatusBarFrame.size.height - oldStatusBarFrame.size.height;
---
Example output demonstrating the bug:
Launched with a single height status bar:
viewDidLoad: the status bar is currently 20 points tall.
Single height to double height:
statusBarWillChange: current status bar frame: {{0, 0}, {320, 40}}
statusBarWillChange: next status bar frame: {{0, 0}, {320, 40}}
statusBarWillChange: the status bar is about to be 0 points taller
statusBarWillChange: BUG DETECTED: the status bar is about to change by 0 points? I'm skeptical of that.
statusBarDidChange: current status bar frame: {{0, 0}, {320, 40}}
statusBarDidChange: old status bar frame: {{0, 0}, {320, 20}}
statusBarDidChange: the status bar just became 20 points taller
Double height to single height:
statusBarWillChange: current status bar frame: {{0, 0}, {320, 20}}
statusBarWillChange: next status bar frame: {{0, 0}, {320, 20}}
statusBarWillChange: the status bar is about to be 0 points taller
statusBarWillChange: BUG DETECTED: the status bar is about to change by 0 points? I'm skeptical of that.
statusBarDidChange: current status bar frame: {{0, 0}, {320, 20}}
statusBarDidChange: old status bar frame: {{0, 0}, {320, 40}}
statusBarDidChange: the status bar just became 20 points shorter
Comments
Please note: Reports posted here will not necessarily be seen by Apple. All problems should be submitted at bugreport.apple.com before they are posted here. Please only post information for Radars that you have filed yourself, and please do not include Apple confidential information in your posts. Thank you!