Using Xcode 4.2/iOS5.0
I have a viewController and an associated viewController.xib. The viewController is set up as the .xib's file's owner. It is invoked from a UINavigationController
.
I am attempting some manual layout when the device is rotated portrait/landscape
As I understand it the UIView
method to override is
- (void)layoutSubviews;
this is where you do the layout
But - as with drawRect
- you do not call this directly, it is invoked when appropriate by iOS
Instead you call setNeedsLayout
...
So I have this in the ViewController
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)
fromInterfaceOrientation {
[[self view] setNeedsLayout];
}
and in the same ViewController I have this
- (void)layoutSubviews {
//.manual override of automatic layout on rotation
NSLog(@"layoutSubviews");
}
However layoutSubviews
does not get called and I don't understand why.
Here is a clue...
If I call layoutSubviews
directly as [self layoutSubviews]
- (void)didRotateFromInterfaceOrientation:(UIInterfaceOrientation)
fromInterfaceOrientation {
[self layoutSubviews];
}
it does trigger
But if I call it as [[self view] layoutSubviews]
it does not
So it appears that the view and it's controller are not wired up correctly?