0

When presenting a ViewController modally with a storyboard segue, the previous ViewController bleeds through.

UIViewController B presents UIViewController C modally. Both of them have UIScrollView (if that matters). 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. 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.

1 Answers1

1

Well, turns out the reason this was occurring was because I had something similar to this in the appdelegate to get black status bars:

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. 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. This kept the window size the same and no more bleeding through.

  • Using code like '[[[UIDevice currentDevice] systemVersion] floatValue] >= 7' is not a very safe way to check for version. What if the version is 7.0.2? You should avoid coding in version-conditionals, but if you cannot avoid it, then a more reliable way is to use NSFoundationNumber and compare it to the constants declared in the Foundation framework, – Joride Oct 02 '15 at 18:09
  • @Joride Hmm I was not aware, do you have any sample code that could show me? – Audrey Hipburn Oct 02 '15 at 18:16
  • Just search for NSFoundationVersionNumber (use SHIFT+CMD+O when in xcode). Note that it is 'NSFoundationVersionNumber', not NSFoundationNumber as I wrote before. – Joride Oct 02 '15 at 18:33
  • You should really watch the Apple tech talk from 2014 'Architecting Modern Apps, Part 2'. This and more important stuff is explained in great detail here. You can find it here: https://developer.apple.com/tech-talks/videos/ – Joride Oct 02 '15 at 19:07