Ok here's the problem if you had some trouble understanding the title.
I'm using this library here and it is represented by the IIViewDeckController
.
I init it with simple left and center UIViewControllers
:
FTPhoneHomeViewController *home = [[FTPhoneHomeViewController alloc] init];
FTPhoneSideViewController *side = [[FTPhoneSideViewController alloc] init];
IIViewDeckController *vdc = [[IIViewDeckController alloc] initWithCenterViewController:home leftViewController:side];
[self.delegate changeRootViewController:vdc];
FTPhoneHomeViewController
and FTPhoneSideViewController
are just subclasses of UIViewController
. The last line removes the current rootViewController
from the window and adds the IIViewDeckController
.
Now in the FTPhoneHomeViewController
I add another UIViewController
with the addChildViewController
method :
FTTileViewController *tileViewController = [[FTTileViewController alloc] initWithFrame:CGRectMake(5.0, 50.0, 469.0, 310) tileData:[FTTileFaker prepareTileData] defaultTileConfig:[FTTileFaker prepareTileConfigs][0] andTileConfigs:[FTTileFaker prepareTileConfigs]];
tileViewController.tileSpacing = 9.0;
[self addChildViewController:tileViewController];
[self.view addSubview:tileViewController.view];
[tileViewController didMoveToParentViewController:self];
I did this because this FTTileViewController
manages a bunch of tiles and from an architectural point of view, this logic is best contained in it's own seperate UIViewController
.
When I use the IIViewDeckController
as a rootViewController
from the window, my viewWillAppear
event in the FTTileViewController
is not called. But it is called in the FTPhoneHomeViewController
! Now when I don't use the IIViewDeckController
and just add the FTPhoneHomeViewController
as the rootViewController
of the window, my FTTileViewController
does get the viewWillAppear
event...
Maybe it's a bug with the IIViewDeckController
and I should also post it there. But I don't see what I'm doing wrong here. Anyone has any thoughts about this?
And if anyone could check my general assumption around UIViewControllers
:
Adding childViewControllers
to another UIViewController
is not a requirement to get view cycle methods (like viewWillAppear
) to be passed onto another UIViewController's
view. These events are passed when you add another UIViewController's
view with the addSubview
method. But you use the addChildViewController
methods for example, to get rotation events and to maintain the viewController's
hierarchy through your application.
Ok to awnser my own question :
In the IIViewDeckController
there are some methods that you can adjust :
- (BOOL)shouldAutomaticallyForwardRotationMethods {
return YES;
}
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
return YES;
}
- (BOOL)automaticallyForwardAppearanceAndRotationMethodsToChildViewControllers {
return YES;
}
return YES from all of them and it should work.
If there is no property for this view containment on the IIViewDeckController
, maybe it's nice to add it?