1

AppDelegate 実装関数 didFinishLaunchingWithOptions に次のコードを追加しました

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {

    [application setStatusBarStyle:UIStatusBarStyleLightContent];

    self.window.clipsToBounds =YES;

   self.window.frame =  CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
    [[NSNotificationCenter defaultCenter] addObserver:self
                                             selector:@selector(applicationDidChangeStatusBarOrientation:)
                                                 name:UIApplicationDidChangeStatusBarOrientationNotification
                                               object:nil];

}

呼び出されているこの関数と同様に:

- (void)applicationDidChangeStatusBarOrientation:(NSNotification *)notification
{
    int a = [[notification.userInfo objectForKey: UIApplicationStatusBarOrientationUserInfoKey] intValue];
   int w = [[UIScreen mainScreen] bounds].size.width;
    int h = [[UIScreen mainScreen] bounds].size.height;

    UIInterfaceOrientation orientation = [UIApplication sharedApplication].statusBarOrientation;
    UIDeviceOrientation orientationa = [[UIDevice currentDevice] orientation];

   if (orientation==4)
    {
        self.window.frame =  CGRectMake(20,0,w-20,h+20);
    }else if(orientation==1)
    {
        self.window.frame =  CGRectMake(0,20,w,h);
    }else
    {
       self.window.frame =  CGRectMake(-20,0,w+20,h+20);
    }
}

これは、回転してもステータスバーが重ならないように機能しますが、バックエンドにリクエストを行うボタンをクリックすると、ステータスバーが変更され、再び回転するまで重なってしまいます。ECSlidingViewController と関係があるのではないかと思いますか?

4

2 に答える 2

1

このコードを試して、Info.plist でこれを設定してください コントローラーベースのステータスバーの外観を表示 = NO

- (void) viewDidLoad
{
    [super viewDidLoad];

    float systemVersion = [[[UIDevice currentDevice] systemVersion] floatValue];

    if (systemVersion >= 7.0f)
    {
        CGRect tempRect;

        for (UIView *sub in [[self view] subviews])
        {
            tempRect = [sub frame];

            tempRect.origin.y += 20.0f; //Height of status bar

            [sub setFrame:tempRect];
        }
    }
}
于 2013-11-27T08:55:20.813 に答える
0

EECCSlidingViewController で ios7 をサポートするには、ナビゲーション コントローラーを使用するときはいつでも、ビュー コントローラー XIB からエッジを拡張するすべてのオプションのチェックを外し、ナビゲーション コントローラーを使用していない場合は、Viewcontroller.m ファイルで以下のコードを使用できます。

-(void)viewDidLayoutSubviews
{
    if([[[UIdevice currentdevice]systemversion]floatvalue] >=7.0f){
    CGRect screen = [UIScreen mainscreen]bounds];
    CGRect frame = self.view.frame;
    frame.origin.y = 20.0f;
    frame.size.height = screen.size.height - 20;
}
  [self.view layoutsubviews];
}

ビューで didfinishlaunching に次を追加します

[application setStatusbarStyle:UIStatusBarStyleTranslucent];

そしてplistファイルでViewControllerBasedStatuschangedAppearenceをNOに追加します

于 2013-11-27T07:07:29.980 に答える