我正在尝试为 UITableView
header 制作自定义 View ,但不幸的是,我遇到了一个异常:
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "ImagesView" nib but the view outlet was not set.'
首先,在 HomeViewController 中我创建了一个 tableView,然后我使用 xib 文件创建了 ImagesViewController,在其中设计了我的自定义 View 。
最后我尝试将 ImagesView 指定为我的 tableView 的标题:
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
ImagesViewController *imagesView = [[ImagesViewController alloc] init];
tableView.tableHeaderView = imagesView.view;
}
我做错了什么?我是iOS开发的新手,自己弄明白了。
感谢您的帮助!
最佳答案
使用这行代码
{
ImageViewcontroller *imageView=[[ImagesViewController alloc]initwithnibname:@"ImageViewController" bundle:nil];
}
关于iphone - 已加载 Nib ,但在为 UITableView 的 header 分配自定义 View 时未设置 View 导出,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10411547/