【问题标题】:HJCache library UITableView IssueHJCache 库 UITableView 问题
【发布时间】:2012-11-28 22:44:09
【问题描述】:

我正在尝试使用 HJCache 库运行我的应用程序以通过网络异步下载图像,但是在将委托和数据源链接到 TableView 后我遇到了这个问题。

-[UIView tableView:numberOfRowsInSection:]: 无法识别的选择器发送到实例 0x7190210 2012-11-29 00:36:41.059 HJCacheTest1[2080:c07] * 由于未捕获的异常“NSInvalidArgumentException”而终止应用程序,原因:'-[UIView tableView:numberOfRowsInSection:]:无法识别的选择器发送到实例 0x7190210'

我的问题可能出在哪里?

首先,我添加了 HJCache 类和 ImageCell.h .m 和 .xib。 其次,我已经将这些类导入到我的 ViewController.m 中并输入了这些代码;

- (void)viewDidLoad
{
[super viewDidLoad];

self.imgMan = [[HJObjManager alloc] init];
NSString* cacheDirectory = [NSHomeDirectory() stringByAppendingString:@"/Library/Caches/imgcache/imgtable/Luai/"] ;
HJMOFileCache* fileCache = [[HJMOFileCache alloc] initWithRootPath:cacheDirectory];
self.imgMan.fileCache = fileCache;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString* cellIdentifier = @"ImgCell";

ImgCell *cell = (ImgCell*)[tableView dequeueReusableCellWithIdentifier:cellIdentifier];

if (cell == nil)
{
    NSArray *nib = [[NSBundle mainBundle] loadNibNamed:cellIdentifier owner:nil options:nil];
    cell = (ImgCell*)[nib objectAtIndex:0];
}

///// Image reloading from HJCacheClasses
[cell.img clear];
NSString *str1 = [imageArray objectAtIndex:indexPath.row];
NSString *trimmedString = [str1 stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceAndNewlineCharacterSet]];
NSURL *url = [NSURL URLWithString:trimmedString];
cell.img.url = url; //set the url to img view
[self.imgMan manage:cell.img];
}

从现在开始谢谢。

【问题讨论】:

  • 谁被设置为您的 tableView、ViewController 或视图的数据源?
  • 数据源设置为 UITableView。
  • +1 格式正确的详细问题

标签: xcode uitableview hjcache


【解决方案1】:

问题在于接口构建器连接错误。

可能的问题:您将 xib 的视图出口连接到 UITableView。

可能的解决方案:重新连接所有 xib 连接。

  1. 将视图出口连接到 xib 中的 UIView
  2. 将 tableView 出口连接到 xib 中的 UItableView
  3. 连接 tableView 数据源并委托给文件的所有者

【讨论】:

  • @LuaiKalkatawi: 很高兴 :) 感谢您的评论
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-11-30
  • 2011-02-03
  • 2012-05-26
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多