1
我想做些什麼,當viewController有任何ChildViewController。iOS Check ViewController有ChildViewController嗎?
我用下面的代碼添加子的viewController:
ParentVC *parentVC = [self.storyboard instantiateViewControllerWithIdentifier:@"IDParentVC"];
ChildVC *childVC = [self.storyboard instantiateViewControllerWithIdentifier:@"IDChildVC"];
[childVC.view setFrame:CGRectMake(0,self.view.frame.size.height, self.view.frame.size.width, self.view.frame.size.height)];
[parentVC addChildViewController:childVC];
[parentVC.view addSubview:childVC.view];
[childVC didMoveToParentViewController:parentVC];
現在如何檢查,如果有ParentVC ChildVC?
'UIViewController'類都有一個'childViewControllers'屬性,你可以枚舉 – Shubhank