0

基本上,我有一個集合視圖誰是cell.contentView增加了一個視圖控制器在的CollectionView的willDisplayCell觀點如下:viewDidLoad中被調用,但viewWillAppear中不叫

-(void)collectionView:(UICollectionView *)collectionView willDisplayCell:(UICollectionViewCell *)cell forItemAtIndexPath:(NSIndexPath *)indexPath { 
    UIViewController *vc = [self.viewControllerArray objectAtIndex:indexPath.row]; 
    [self displayContentController:vc inView:cell]; 
} 

- (void)displayContentController:(UIViewController *)viewController inView: (UICollectionViewCell *)cell { 
    [self addChildViewController:viewController]; 
    viewController.view.frame = cell.bounds; 
    [cell.contentView addSubview:viewController.view]; 
    [viewController didMoveToParentViewController:self]; 
} 

現在,這個視圖控制器具有的tableView。在tableview的didSelectRowAtIndexpath中,我推送了一個New ViewController。

令人驚訝的是,推送的ViewController的viewDidLoadviewDidLayoutSubviews被調用,但不調用viewWillAppear

我也收到以下警告在控制檯Unbalanced calls to begin/end appearance transitions for <viewController Having collection View>

我不知道我做錯了什麼。

甚至嘗試過與cellForRowAtIndexPath但不是運氣。

回答

0

需要將ViewController添加到UINavigationController堆棧!

相關問題