我發現有很多答案,我所遇到的問題,在這裏,想請教一個問題,第一次(我是一個新手,以尋求幫助!)的iOS的TableView細胞
我實現將SDWebImage
框架合併到使用JSON
解析數據填充UITableViewController
的項目中。圖像正在緩存成功,但當應用程序第一次啓動時,所有的細胞圖像都不存在。只有當我向上或向下滾動並出現行時(或者當我點擊它們來選擇一行時),它們纔會出現。如果我回到它,所有的圖像緩存和工作正常。這只是第一次發佈,我錯過了我的所有圖片。我粘貼了我在這裏的內容,希望有人能發佈一個簡單的解決方案。感覺這是一件小事,我必須做,以使它們在首次發佈時出現。
代碼如下:
static NSString *MyIdentifier = @"Maincell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:MyIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:MyIdentifier];
}
UIFont *wireBold = [UIFont fontWithName:@"Helvetica" size:14.0f];
cell.textLabel.text = [[news objectAtIndex:indexPath.row]objectForKey:@"Title"];
cell.textLabel.font = wireBold;
cell.textLabel.textColor = [UIColor blackColor];
UIFont *wireSub = [UIFont fontWithName:@"Sintony" size:10.0f];
cell.detailTextLabel.text = [[news objectAtIndex:indexPath.row]objectForKey:@"Name"];
cell.detailTextLabel.font = wireSub;
cell.detailTextLabel.textColor = [UIColor grayColor];
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
NSString *filePath = [[news objectAtIndex:indexPath.row]objectForKey:@"Image"];
NSString *urlString = [NSString stringWithFormat:@"http://www.mywebhost/images/%@.png",filePath];
[cell.imageView setImageWithURL:[NSURL URLWithString:urlString] placeholderImage:[UIImage imageNamed:@"placeholder.png"]];
return cell;
感謝您的線索!我在項目目錄中有文件,但沒有使用'添加文件到'「'來添加它。現在一切正常。 –
非常感謝,我一直在爲此工作,直到昨晚凌晨3:45和今晚12:30,所以纔有時間睡一覺,因爲我一直靠着4個大杯咖啡過日子!非常感謝我需要的線索。 –