在 loggerViewController.m 中:
- (void)viewDidLoad
{
[super viewDidLoad];
UIView* mainView = [[UIView alloc] initWithFrame:[UIScreen mainScreen].bounds];
[self.view addSubview:mainView]; // <-- Problem is here
}
loggingViewController 是我的 appDelegate 的 iVar
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
.
.
loggingViewController = [[loggerViewController alloc] init];
[loggingViewController.view setBackgroundColor:[UIColor blueColor]];
// [loggingViewController loadView];
[self.view addSubview:loggingViewController.view];
}
我期待我的 AppDelegate 调用 loggingViewController,然后它会在里面设置它自己的子视图并且它会完成。但是相反, viewDidLoad 被递归调用,我不明白为什么?