简体   繁体   English

阻止UITableView节标题继续滚动

[英]Stop UITableView section headers from moving on scroll

I have the following code: 我有以下代码:

 func tableView(tableView: UITableView, willDisplayHeaderView view: UIView, forSection section: Int) {
    let header: UITableViewHeaderFooterView = view as! UITableViewHeaderFooterView
    header.frame.insetInPlace(dx: 55, dy: 0)
}

I am moving view over 55 so that it won't be overlapped by the center view as this view is a right side panel. 我将视图移至55,以使它不会与中心视图重叠,因为该视图是右侧面板。 As soon as I scroll the table view in that side panel, the position seems to revert, making my labels disappear under the center view. 当我在该侧面板中滚动表格视图时,该位置似乎恢复了,使我的标签消失在中央视图下。 If I collapse the side menu and reopen it, the position is reset. 如果我折叠侧面菜单并重新打开,则位置将重置。 I want the view to stay at 55. What should I do? 我希望视图保持在55。该怎么办?

Instead of trying to just move the section header position I decided to move the entire child view controller over. 我决定不移动整个节头位置,而是决定移动整个子视图控制器。 That way I don't need to manipulate the position of all the section headers and cell labels/icons. 这样,我就不需要操纵所有节标题和单元格标签/图标的位置。 It was just a lot easier for me all around. 这对我周围的人来说要容易得多。

So as an answer, consider moving the underlying view. 因此,作为答案,请考虑移动基础视图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM