なにこれ……
AppDelegate.h
//
// AppDelegate.m
// SimpleNestedViewController
#import "AppDelegate.h"
@interface ChildViewController : UIViewController
@end
@implementation ChildViewController
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
NSLog(@"iOS5だとviewWillAppear:が呼ばれない");
}
@end
@interface ParentViewController : UIViewController
@end
@implementation ParentViewController
- (void)viewDidAppear:(BOOL)animated
{
[super viewDidAppear:animated];
ChildViewController* childViewController = [ChildViewController new];
[self addChildViewController:childViewController];
[self.view addSubview:childViewController.view];
[childViewController didMoveToParentViewController:self];
dispatch_async(dispatch_get_main_queue(), ^{
// ここに移動するとNSLog呼ばれる
});
}
@end
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [ParentViewController new];
[self.window makeKeyAndVisible];
return YES;
}
@end
(iOS SDK 7.1 / iOS 5.1.1 で確認)