菜鸟教程小白 发表于 2022-12-13 11:50:15

ios - 什么是 "dequeue cell"


                                            <p><p>你能帮我解释一下<a href="https://developer.apple.com/library/ios/documentation/UIKit/Reference/UITableView_Class/index.html#//apple_ref/occ/instm/UITableView/dequeueReusableCellWithIdentifier:forIndexPath:" rel="noreferrer noopener nofollow">dequeueReusableCellWithIdentifier:forIndexPath</a> 中“dequeue cell”的详细信息,以及什么是“resize proper”吗?方法?</p></p>
                                    <br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
                                            <p><p>出列单元格:-为指定的重用标识符返回一个可重用的表格 View 单元格对象并将其添加到表格中。</p>

<p>创建表格 View 单元格</p>

<ul>
<li>registerNib:forCellReuseIdentifier:</li>
<li>registerClass:forCellReuseIdentifier:</li>
<li>dequeueReusableCellWithIdentifier:forIndexPath:</li>
<li>dequeueReusableCellWithIdentifier:</li>
</ul>

<p>有关这些委托(delegate)方法的更多描述,请参阅苹果文档,
<a href="https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instm/UITableView/dequeueReusableCellWithIdentifier:forIndexPath" rel="noreferrer noopener nofollow">https://developer.apple.com/library/prerelease/ios/documentation/UIKit/Reference/UITableView_Class/#//apple_ref/occ/instm/UITableView/dequeueReusableCellWithIdentifier:forIndexPath</a> :</p>

<p>这是在方法<em>cellforrowatindexpath</em>中为表格 View 添加出列单元格方法的方式。</p>

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

    UITableViewCell *cell = ;
    if (cell == nil) {
      cell = [[ initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease];
      cell.textLabel.text = ;
    }   
    return cell;
}
</code></pre>

<p>这是正确调整大小的方法及其作用。</p>

<p><code>- (__kindof UITableViewCell *)dequeueReusableCellWithIdentifier:(NSString *)identifier forIndexPath:(NSIndexPath *)indexPath NS_AVAILABLE_IOS(6_0);
   //较新的出队方法保证单元格被返回并正确调整大小,假设标识符已注册</code></p>

<p>这里是 swift 中同一个 TableView 出列单元格的教程
<a href="https://thatthinginswift.com/table-data-sources/" rel="noreferrer noopener nofollow">https://thatthinginswift.com/table-data-sources/</a> </p>

<p> <a href="http://shrikar.com/uitableview-and-uitableviewcell-customization-in-swift/" rel="noreferrer noopener nofollow">http://shrikar.com/uitableview-and-uitableviewcell-customization-in-swift/</a> </p></p>
                                   
                                                <p style="font-size: 20px;">关于ios - 什么是&#34;dequeue cell&#34;,我们在Stack Overflow上找到一个类似的问题:
                                                        <a href="https://stackoverflow.com/questions/33029472/" rel="noreferrer noopener nofollow" style="color: red;">
                                                                https://stackoverflow.com/questions/33029472/
                                                        </a>
                                                </p>
                                       
页: [1]
查看完整版本: ios - 什么是 &#34;dequeue cell&#34;