Search code examples
iosobjective-cuiviewuiviewcontrollerviewwillappear

self.view.frame/bounds of UIViewController changed between viewDidLoad and viewWillAppear iOS8


I have a really strange problem with a view in my iPhone App.

I have two UIViewController subclasses A and B.

A UIViewController of class B (Let´s call it b) is called from a method inside of a UIViewController of A (a). But when b is displayed, the frame and the bounds of the "root" view of b changed magically between the calls of viewDidLoad and viewWillAppear. I have no idea, why this happens. As far as I know, all my other views do not have this problem.

These are the frames and bounds:

in viewDidLoad:

self.view.frame: {0, 0}, {375, 667}

self.view.bounds: {0, 0}, {375, 667}

in viewWillAppear::

self.view.frame: {0, 64}, {375, 554}

self.view.bounds: {0, 0}, {375, 554}

I made a screenshot to demonstrate the problem. The yellow area is the self.view of b. the red and green ones are subviews of self.view. They are just there for my layouting. I don´t think they have any effects on the self.view frame or bounds.

Does anyone have an idea what causes this problem?

UIViews in b


Solution

  • Okay, after hours (literally!) of debugging I found my error: I forgot to call self = [super init]; in my custom init method. That caused some weird behaviour.

    Thanks for your helpful comments!