【问题标题】:Custom uitableviewcell not working in LazyTableImages自定义 uitableviewcell 在 LazyTableImages 中不起作用
【发布时间】:2023-03-16 19:56:01
【问题描述】:

我在我的应用程序中使用自定义 UITableView 单元格,并且我已集成 LazyTableImages 示例代码以在 tableview 中下载图像。我在

中使用以下代码
- (void)appImageDidLoad:(NSIndexPath *)indexPath
    {
        IconDownloader *iconDownloader = [imageDownloadsInProgress objectForKey:indexPath];
        if (iconDownloader != nil)
        {
            CustomTblViewCell *cell = (CustomTblViewCell *)[self.TblView cellForRowAtIndexPath:iconDownloader.indexPathInTableView];

            // Display the newly loaded image
            cell.ImgViewUser.image = iconDownloader.appRecord.m_strImage;
        }

        // Remove the IconDownloader from the in progress list.
        // This will result in it being deallocated.
        [imageDownloadsInProgress removeObjectForKey:indexPath];
        [m_CtrlTblViewFacetoface reloadData ];
}

上面的代码没有加载任何数据,但是当我使用 UITableView 单元格而不是 Customcell 时,它正在工作,知道吗?

【问题讨论】:

标签: iphone objective-c ios ipad uitableview


【解决方案1】:

只是有一个我以前用过的库,它运行良好,这个库叫做“ SDWebImage”,你可以简单地通过一个方法来使用它:

[cell.ImgViewUser setImageWithURL:[NSURL URLWithString:@"http://www.domain.com/path/to/image.jpg"]
               placeholderImage:[UIImage imageNamed:@"placeholder.png"]];

它会自动缓存图像,并且只支持从缓存中加载(如果需要)并自动处理内存警告。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2019-11-30
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-02-24
    • 2021-08-09
    相关资源
    最近更新 更多