我有一个 ProfileViewController,其中有一个容器 View ,它是一个 Collection View Controller ,当在容器 View 中选择一个项目时,它将把整个 ProfileViewController 推送到 ProfileViewController 的另一个实例。这是我的代码:
- (void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath: (NSIndexPath *)indexPath {
ProfileViewController *profileVC = [[ProfileViewController alloc] init];
profileVC.user = self.friends[indexPath.item];
UIViewController *parentVC = self.parentViewController;
[parentVC.navigationController pushViewController:profileVC animated:YES];
}
然而,当它把整个 View Controller 推到黑屏上时(选项卡和导航栏仍然显示)。任何帮助如何解决这个问题?
最佳答案
您可能需要使用 nib 文件初始化 ProfileViewController
,可能类似于:
ProfileViewController *profileVC = [[ProfileViewController alloc] initWithNibName:@"ProfileViewController"bundle:nil];
字符串@"ProfileViewController"需要替换为调用此 View Controller 的任何.xib 文件。无论如何,您首先如何实例化 View Controller ?你在使用 Storyboard吗?
关于ios - 从容器 View 以编程方式推送以查看 Controller ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24269818/