美文网首页iOS学习笔记
Swift设置section高度为0的方法

Swift设置section高度为0的方法

作者: ZYiDa | 来源:发表于2018-01-04 10:06 被阅读31次

只设置section高度而不做其它处理时,在OC下面找到

- (CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section;
- (CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section;

然后return 0.00001就可以了
但是,在swift中只是这样设置,是无效的,还要做如下处理

    public func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        return UIView.init()
    }
    public func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        return UIView.init()
    }

这样,就可将section的高度设置为0了。

不对的地方,还请各位多多指教。

相关文章

网友评论

    本文标题:Swift设置section高度为0的方法

    本文链接:https://www.haomeiwen.com/subject/dqnlnxtx.html