我正在制作一个加载了一些 NSArray 的表格视图,该单元格包含两个标签和一个加载了 URL 图像的背景图像视图。问题是 tableview 的滚动很慢,就像冻结或其他什么......我认为这是因为 Imageview 但我能做什么???
这是我的一些代码,以便您可以看到:
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
// Return the number of rows in the section.
return _Title.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
MyCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
int row = [indexPath row];
cell.TitleLabel.text = _Title[row];
cell.DescriptionLabel.text = _content[row];
cell.CellImageView.image = [UIImage imageWithData:[NSData dataWithContentsOfURL:[NSURL URLWithString:_ImageUrl[row]]]];
cell.CellImageView.contentMode = UIViewContentModeTop;
cell.CellImageView.contentMode = UIContentSizeCategoryMedium;
cell.backgroundColor = [UIColor clearColor];
return cell;
}
对于额外信息,此表视图提供了具有相同信息的 Detailviewcontroller。
异步加载图像(图像进入时加载)。研究一些很棒的课程,例如SDWebImage
https://github.com/rs/SDWebImage https://github.com/rs/SDWebImage
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)