iphone - 已加载 Nib ,但在为 UITableView 的 header 分配自定义 View 时未设置 View 导出

标签 iphone objective-c ios xcode cocoa-touch

我正在尝试为 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/

相关文章:

iphone - 我可以将 iPhone 应用程序设置为在用户打开电子邮件附件时运行吗?

具有 Accelerate 框架 vDSP 的 iPhone FFT

iOS UItableviewCell 清除旧的单元格值

iphone - pdf在模拟器中显示但在iPhone中不显示

ios - 替换多线程核心数据中的数据

iphone - 如何从服务器导入图像并将其排列在 View 中

iphone - 在 iPhone 应用程序中捕获 60fps

iphone - 在iOS上,使用NSURLConnection时如何缓存更大的文件(1MB)?

ios - 动态添加内容到 UIScrollView

ios - SUBQuery NSPredicate