1

ネット経由で画像を非同期にダウンロードするために HJCache ライブラリを使用してアプリを実行しようとしていますが、デリゲートと dataSource を TableView にリンクすると、この問題が発生します。

-[UIView tableView:numberOfRowsInSection:]: 認識されないセレクターがインスタンス 0x7190210 2012-11-29 00:36:41.059 HJCacheTest1[2080:c07] に送信されました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 に答える