myell0w / MTStatusBarOverlay

A custom iOS status bar overlay seen in Apps like Reeder, Evernote and Google Mobile App
MIT License
1.92k stars 325 forks source link

StatusBarOverlay has wrong transform applied when firstly shown in Landscape mode #13

Closed krasnyk closed 12 years ago

krasnyk commented 13 years ago

Take StatusOverlay version from b2969135c24965a25da921ede03c84e176c842db or download sample project from: http://www.DropBox.pl/file.php?name=217657578780A35E905C5FACEC9C80B7

Steps to reproduce:

  1. We will deploy the app to the device. Please make sure that device is in LandscapeLeft orientation before the app gets uploaded to the device.
  2. Upload app to the device
  3. StatusOverlay has wrongly setup transform. It is not synchronized with current status bar orientation. I would suggest to check the statusBar orientation in initWithFrame method using [UIApplication sharedApplication].statusBarOrientation. The above bug occurs also in a simulator. Result image can be found at: http://www.DropBox.pl/file.php?name=911648151B4D283D2AD89C86774F27F5

I guess the following is also connected with the above one:

  1. We will deploy app to the device. Please make sure that the device is in LandscapeRight orientation before the app gets uploaded to the device.
  2. Upload to the device.
  3. StatusOverlay is not displayed at all.
grgcombs commented 13 years ago

Yep, on an iPad there's a 50% chance the status bar overlay will appear in the incorrect device orientation. I've also seen it where the bar is horizontal, but the text messages partially appear vertical within it (only 2 or 3 characters will show, vertically).

Unfortunately, I can't get this to reproduce on the simulator and it seems to happen sporadically on the device. I wonder if this has to do with it being face-up (makes it difficult to determine proper orientation?)

bluesuedesw commented 13 years ago

Can't use this nifty tool in the iPad version of my app due to this issue.

If it is launched in LandscapeLeft, not only will the status bar overly not work as intended, but any posted messages will black out the entire screen with a super large progress indicator on the sim and device w/iOS 4.3.

grgcombs commented 13 years ago

The fix for me was to move the first call that instantiates the MTStatusBarOverlay until after my view controllers are up and running in the UIWindow. ... If you instantiate the statusBarOverlay too soon, it basically get's tangled up in UIWindow's weird-ass orientation conversions ... UIWindow actually runs and draws everything assuming it's in portrait, even on the iPad ... it then transforms the orientation and drawing for the view controllers that attach to it, making them appear to be the correct side up, even though it's still handling it's own business in portrait only.... good times.

coneybeare commented 12 years ago

Ya, this is a big issue. I delay mine right up until needed in my app and it still turns out horrible when the app is launched in landscape.

coneybeare commented 12 years ago

After trying to solve this the right way all day, I finally settled on just a hack that seems to work. If you forcefully set the orientation to portrait before the MTStatusBarOverlay initWithFrame: call, then set it back after it works.

- (id)initWithFrame:(CGRect)frame {
    UIInterfaceOrientation orient = [[UIApplication sharedApplication] statusBarOrientation];
    if ((self = [super initWithFrame:frame])) {
        [[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait animated:NO];
        …
        …
        …
        [[UIApplication sharedApplication] setStatusBarOrientation:orient animated:NO];
    }
    return self;
}

There is no visual glitch of the status bar or anything, but it still feels wrong.

myell0w commented 12 years ago

This issue was finally fixed in f908a89c5f7108327120c103ee1ee09abc67a4b9, thank to @gekitz !