简体   繁体   English

在iOS7上模态显示时,以前的UIViewController会流血

[英]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: 看起来像这样:

1个

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.

相关问题 在以模态显示的UIViewController中使用UITableView时的奇怪行为 - Odd behaviour when using UITableView in a UIViewController that is presented Modally 确定是否以模态方式呈现UIViewController - Determining if a UIViewController is being presented modally 当 UIViewController 以模态呈现时,UINavigationController(在 UITabBarController 选项卡内)丢失堆栈 - UINavigationController (Inside a UITabBarController tab) losing stack when a UIViewController is presented modally 呈现的UIViewController模态显示移到顶部 - UIViewController presented modally show up shifted to the top 获取最高的 UIViewController(如果以模态方式呈现) - Get top most UIViewController if its presented modally iOS 关闭模态呈现视图时黑屏 controller - iOS Black screen when close modally presented view controller “viewWillTransitionToSize:”当视图控制器以模态呈现时不会在 iOS 9 中调用 - "viewWillTransitionToSize:" not called in iOS 9 when the view controller is presented modally 模态呈现的UIViewController在关闭时不会清空内存 - Modally presented UIViewController does not empty memory on close 以模态呈现的UIViewController的背景颜色随机变化 - Background Color Randomly Changes of UIViewController presented Modally UIPopoverController以模态方式呈现在iOS 5中不起作用 - UIPopoverController presented modally doesn't work in iOS 5
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM