我在 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 有关?