加载自定义的UITableViewCell从故事板 [英] Load custom UITableViewCell from Storyboard
问题描述
目前我使用的自动布局,情节串连图板动态调整自定义的的UITableViewCell
的。一切工作,因为它应该除外存在内存泄漏滚动时。
Currently I'm using auto layout with storyboard to dynamically resize custom UITableViewCell
's. Everything is working as it should except there is memory leak when scrolling.
我知道这个问题是从调用
I know the problem is from calling
[self.tableView dequeueReusableCellWithIdentifier:CellIdentifier];
这里面
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
我的问题是,什么是创建一个参考单元的最佳方式?如何加载从故事板细胞无 dequeueReusableCellWithIdentifier
?
和是否确定,也许叫 dequeueReusableCellWithIdentifier
从 viewDidLoad中
并创建一个引用单元格作为属性?
And is it ok to maybe call dequeueReusableCellWithIdentifier
from viewDidLoad
and create a reference cell as a property?
我需要参考单元浆纱的目的。
I need reference cell for sizing purposes.
感谢您的帮助。
推荐答案
关于如何创建引用的单元格(见原题),有几个选项,我可以看到:
Regarding how to create reference cell (see original question), there are couple of options as I can see:
-
创建XIB自定义单元格,在这里大文章 - >的链接!
- 这是向我指出由@smileyborg,谢谢!
创建code您的自定义单元格,用限制一起。
create your custom cell in code, along with constraints.
在故事板作为原型细胞创建自定义单元格
create your custom cell in storyboard as prototype cell
- 后,有2个选择:
- 将和表视图拖放自定义单元格的故事板的场景,作为一个顶级笔尖对象(不是视图层次的一部分),而只需创建出口吧。
- 复制自定义单元格并将其粘贴到故事板的场景。当以此方式使用它,也没有必要与表登记原始细胞对出列。
- 这两种方式的小问题是,一旦你拖放自定义单元格的故事板的场景,你将无法直观地看到它,并安排用户界面。
谢谢大家的帮助!
这篇关于加载自定义的UITableViewCell从故事板的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!