1

我正在尝试使用 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];
}

从现在开始感谢。

4

1 回答 1

1

问题在于错误的界面构建器连接。

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

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

  1. 将视图出口连接到 xib 中的 UIView
  2. 将 tableView 插座连接到 xib 中的 UItableView
  3. 连接 tableView 数据源并委托给文件的所有者
于 2012-11-29T11:03:51.530 回答