如何回收从XIB创建的UITableViewCell对象? [英] How can I recycle UITableViewCell objects created from a XIB?
问题描述
我想使用XIB创建自定义UITableViewCell,但是我不确定如何使用UITableViewController的排队机制对其进行回收.我该怎么做?
I'd like to create custom UITableViewCell using an XIB, but I'm not sure how to recycle it using UITableViewController's queueing mechanism. How can I accomplish this?
很高兴,尽管我喜欢很棒的回答,但根据常见问题解答可以自行回答此问题.投票赞成,请自己喝杯啤酒.我之所以这样问,是因为有朋友问我,我想把它放在StackOverflow上.如果您有任何贡献,请务必!
Folks, this question was intended to be self answered as per the FAQ, although I love the awesome responses. Have some upvotes, treat yourself to a beer. I asked this because a friend asked me and I wanted to put it up on StackOverflow. If you have anything to contribute, by all means!
推荐答案
如果您使用的是iOS 5,则可以使用
If you're using iOS 5 you can use
[self.tableView registerNib:[UINib nibWithNibName:@"nibname"
bundle:nil]
forCellReuseIdentifier:@"cellIdentifier"];
然后在您致电时
cell = [tableView dequeueReusableCellWithIdentifier:@"cellIdentifier"];
tableview将加载笔尖并为您提供一个单元格,或者为您出队一个单元格!
the tableview will either load the nib and give you a cell, or dequeue a cell for you!
笔尖只需是在其中定义了单个tableviewcell的笔尖!
The nib need only be a nib with a single tableviewcell defined inside of it!
这篇关于如何回收从XIB创建的UITableViewCell对象?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!