I have 1 UIView
which will be added to my UITableViewCell
like this. Although it will be called only 1 time, I feel like it is expensive to do. (At first time, it lag. After scroll up and down, it is fast since it is already created) How can I create that view so that it can be reused again and again for other cell as well (no need to init again)?
- (void)awakeFromNib
{
// Initialization code
self.vwHeaderWithUserAction = [HeaderWithUserActionInListing loadFromNib];
self.vwHeaderWithUserAction.delegate = self;
self.vwHeaderWithUserAction.viewTypeInUserAction = ViewTypeInUserActionInListing;
[self.contentView addSubview:self.vwHeaderWithUserAction];
}
In cellForRowAtIndexPath method check whether that view is existing if not create new one otherwise use existing one.
- (UITableViewCell *)tableView:(UITableView *)tableViewLocal cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (!myview)
{
// Initialize myView
}
// Do Necessary things
[cell.contentView addSubview:myview];
}
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.