0

This is my issue....

enter image description here

This happens when:

  1. Status bar is faded out using the button.
  2. Rotate 180 deg from landscape to upside-down landscape.
  3. Status bar is faded back in using the button. - it now covers the navigation bar.

The button code to toggle the status bar visibility:

- (IBAction)toggleBar:(id)sender
{
    NSLog(@"View Frame : %@", NSStringFromCGRect(self.view.frame));

    // Toggle status bar visiblity
    BOOL isStatusBarHidden = [[UIApplication sharedApplication] isStatusBarHidden];
    [[UIApplication sharedApplication] setStatusBarHidden:!isStatusBarHidden
                                            withAnimation:UIStatusBarAnimationFade];
}

The view always reports its frame to be 480 x 288.

The issue was fixable on iOS 5 using a hacky workaround, by stopping the rotation filling the space.

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    if ([[UIApplication sharedApplication] isStatusBarHidden])
    {
        float oldAlpha = self.navigationController.navigationBar.alpha;
        self.navigationController.navigationBar.alpha = 0.01;
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

        double delayInSeconds = 0.0;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            self.navigationController.navigationBar.alpha = oldAlpha;
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
        });
    }

    return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

This dons't work on iOS 6 because shouldAutorotateToInterfaceOrientation is not called. However, using its replacement: willRotateToInterfaceOrientation also dosn't work. Any ideas?

4

4 回答 4

0

切换状态栏后,再次设置 self.view.frame。

于 2013-02-05T17:41:20.250 回答
0

我打电话后

解除视图控制器动画

这个方法,然后调用

[[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide];

出现这个问题。

当我调用 [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationSlide]; 首先,没问题。

于 2015-04-09T06:22:51.220 回答
0

在IOS6,你应该使用这些方法。检查这些。

- (BOOL)shouldAutorotate
{
    //returns true if want to allow orientation change
    return TRUE;
}
- (NSUInteger)supportedInterfaceOrientations
{   
     //decide number of origination tob supported by Viewcontroller.
     return UIInterfaceOrientationMaskAll;
}

- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
    //from here you Should try to Preferred orientation for ViewController 
}
于 2013-02-05T17:53:08.333 回答
0

好的,答案是使用相同的技巧,willRotateToInterfaceOrientation我曾说过这在我的问题中不起作用,但我只是再次尝试并成功了。

- (void) willRotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration
{
    if ([[UIApplication sharedApplication] isStatusBarHidden])
    {
        [[UIApplication sharedApplication] setStatusBarHidden:NO withAnimation:UIStatusBarAnimationNone];

        double delayInSeconds = 0.0;
        dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, (int64_t)(delayInSeconds * NSEC_PER_SEC));
        dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
            [[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
        });
    }
}
于 2013-02-05T18:37:52.793 回答