[英]Previous UIViewController bleeds through when presented modally on iOS7
When presenting a ViewController modally with a storyboard segue, the previous ViewController bleeds through. 在以情节提要板模式形式呈现ViewController时,以前的ViewController会流血。
UIViewController B presents UIViewController C modally. UIViewController B以模态形式显示UIViewControllerC。 Both of them have UIScrollView
(if that matters). 他们两个都有UIScrollView
(如果有的话)。 When I get to ViewController C, it's almost as though the the entire view is just a tiny bit smaller so that the previous ViewController bleeds through. 当我进入ViewController C时,几乎就像整个视图都小了一点,这样以前的ViewController就可以通过了。 It looks something like this: 看起来像这样:
The bottom light grey is part of the previous controller. 底部的浅灰色是先前控制器的一部分。 The way I actually confirmed it was the previous view controller is I added this method to it: 我实际上确认它是先前的视图控制器的方式是在此方法中添加了此方法:
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event {
NSLog(@"I'm being touched!");
}
This only occurs in iOS 7 and not on iOS 8. 这只会在iOS 7中发生,而不会在iOS 8中发生。
Well, turns out the reason this was occurring was because I had something similar to this in the appdelegate to get black status bars: 好吧,原来发生这种情况的原因是因为我在appdelegate中有类似的东西来获取黑色状态栏:
if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7) {
[application setStatusBarStyle:UIStatusBarStyleLightContent];
[application setStatusBarHidden:NO withAnimation:UIStatusBarAnimationFade];
self.window.clipsToBounds =YES;
self.window.frame =CGRectMake(0,20,self.window.frame.size.width,self.window.frame.size.height-20);
}
This was an issue because it was changing the entire window size. 这是一个问题,因为它正在更改整个窗口的大小。 It wasn't causing an issue in the first view, but fo some reason it was causing an issue during modal segue's. 乍一看,这并不是造成问题的原因,但是出于某种原因,它在模态segue期间造成了问题。 So to fix it I changed it to something similar to: 因此,要解决此问题,我将其更改为类似于以下内容的内容:
if (IS_IOS7) {
UIView *addStatusBar = [[UIView alloc] init];
addStatusBar.frame = CGRectMake(0, 0, 320, 20);
addStatusBar.backgroundColor = [UIColor colorWithRed:0 green:0 blue:0 alpha:1]; //You can give your own color pattern
[self.window.rootViewController.view addSubview:addStatusBar];
}
This method seemed to work better because instead of changing the window size, I was simply adding a UIView that was black to the top of the frame. 这种方法似乎更好用,因为我无需更改窗口大小,而只是在框架顶部添加了一个黑色的UIView。 This kept the window size the same and no more bleeding through. 这样可以使窗口大小保持不变,并且不会再渗出。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.