Swift的一些坑(UITableview引用自定义View和自定义Cell)

UITableview

我首先用的storyboard上的tableview初始化了

UITableController

第一行是自定义的collectionview放在了cell里 里面是自定义的Collectioncell

第二行是自定义的headerview

第三行是自定义的Cell

首先tableview自动计算autolayout高度的方法是可以用的

tableView.estimatedRowHeight=200;

tableView.rowHeight=UITableViewAutomaticDimension;

初始化自定义view

引用

private lazy var headerView:HeaderView= {

let h =HeaderView.loadFromNib()

return h

}()

view本身从nib加载

class func loadFromNib() ->HeaderView{

return NSBundle.mainBundle().loadNibNamed("Header", owner:self, options:nil).last as! HeaderView

}

加载SectionHeaderView

let view = tableView.dequeueReusableCellWithIdentifier(kSectionHeaderViewReuseIdentifier) as! SectionHeaderView

//kSectionHeaderViewReuseIdentifier 是Identifier


加载自定义cell

let cell = tableView.dequeueReusableCellWithIdentifier(kHotCellReuseIdentifier, forIndexPath: indexPath) as! HotCell

//kHotCellReuseIdentifier 是Identifier

UICollection跟上面差不多。

附加:

Swift第三方库

网络库 Alamofire

AutoLayout库  SnapKit

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容