菜鸟教程小白 发表于 2022-12-11 16:57:33

从 URL 显示大尺寸图像时,iOS 应用程序崩溃


                                            <p><p>我尝试了以下用于图像缓存的库:</p>

<ul>
<li><p><strong>SDWebImage</strong></p></li>
<li><p><strong>UIImageView+AFNetworking</strong></p></li>
</ul>

<p>但应用在滚动时仍收到<strong>内存警告、崩溃和卡住</strong>。</p>

<p>我使用 <code>UITableViewCell</code> 来显示图像。</p>

<p>部分<strong>图片为 1.5 MB 或更大</strong>,所以我不确定这是问题所在还是其他问题?</p>

<p>请指导。
您的任何努力将不胜感激。</p>

<p><strong>编辑:</strong></p>

<p>我有 <code>UITableViewCell</code> 用于在 <code>UITableView</code> 中加载 <code>UICollectionViewCell</code>:</p>

<p><strong>UITableViewCell 的代码。</strong></p>

<pre><code>- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    static NSString *simpleTableIdentifier = @&#34;homecell&#34;;

    HomeViewCell *cell = (HomeViewCell *);
    if (cell == nil)
    {
      NSArray *nib = [ loadNibNamed:@&#34;HomeViewCell&#34; owner:self options:nil];
      cell = ;
    }

    NSArray *arr=[ valueForKey:@&#34;PostImage&#34;];
    ;

    return cell;
}
</code></pre>

<p><strong>UICollectionViewCell 的代码。</strong></p>

<pre><code>- (UICollectionViewCell *)collectionView:(UICollectionView *)collectionView1 cellForItemAtIndexPath:(NSIndexPath *)indexPath{

    static NSString *cellIdentifier = @&#34;ScrollCollectionCell&#34;;
    ScrollCollectionCell *cell = ;

    NSString *imgKey = (IS_IPAD?@&#34;PostImage&#34;:@&#34;PostImage&#34;);
    NSString *strImage=];

    placeholderImage:];

    if (==1) {

      self.pageControllPostImg.hidden=TRUE;
    }
    self.pageControllPostImg.hidden=TRUE;
    self.pageControllPostImg.numberOfPages=;
    return cell;
}
</code></pre></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>我在一个项目中遇到过这个问题,以前的程序员每次都创建新单元格并且没有使用可重复使用的单元格。</p></p>
                                   
                                                <p style="font-size: 20px;">关于从 URL 显示大尺寸图像时,iOS 应用程序崩溃,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/38310208/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/38310208/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: 从 URL 显示大尺寸图像时,iOS 应用程序崩溃