Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

安全边距问题 #467

Open
forkdog opened this issue Oct 17, 2022 · 5 comments
Open

安全边距问题 #467

forkdog opened this issue Oct 17, 2022 · 5 comments
Labels
question Further information is requested

Comments

@forkdog
Copy link

forkdog commented Oct 17, 2022

安全边距问题,请求修改下JXPagingView.swift

    open func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier, for: indexPath)
        cell.selectionStyle = .none
        cell.backgroundColor = UIColor.clear
        if listContainerView.superview != cell.contentView {
            cell.contentView.addSubview(listContainerView)
        }
        if listContainerView.frame != cell.contentView.bounds {
            listContainerView.frame = cell.contentView.bounds
        }
        return cell
    }

版本号
1.JXPagingView版本号:2.1.2
2.OC还是Swift版本:swift

@wkjCoder
Copy link

OC版本同样遇到底部留白问题,考虑或许也是安全边距问题

@Tory-Xu
Copy link

Tory-Xu commented Dec 7, 2022

@forkdog 通过这种方式修改部分系统上还是会存在问题。

场景:竖屏切换到横屏
系统:iPhone 11 iOS 14.1(模拟器), iPhone 13 iOS 15.6.1(真机) - - 个人使用设备情况
注:iPhone 14 iOS 16.0 模拟器正常

在上述设备的情况下,在竖屏切换到横屏的过程中,tableView 的 layoutSubview 方法会被执行,此时在 cellForRow 中获取到 cell.contentView.frame 包含安全区域的空间;在横竖屏结束之后,contentView.frame 会发生变化,减少了左右安全区域的宽度。而 contentView frame 变化时不会重新调整 listContainerView 的 frame,最后 listContainerView 的大小会出现错误。

我的解决方案:
这里的布局方式替换成约束布局

@ebamboo
Copy link

ebamboo commented Mar 29, 2023

iOS 16.1 下运行会出现底部空白,iOS14.1下运行正常显示

@ebamboo
Copy link

ebamboo commented Mar 29, 2023

底部空白的高度应该是安全区域的底部间距,所以多计算了一次距离导致底部留白

@pujiaxin33
Copy link
Owner

参考swift版本demo中的【列表是VC示例】,给list tableView设置tableView.contentInsetAdjustmentBehavior = .never,就不会有底部的安全边距。

@pujiaxin33 pujiaxin33 added the question Further information is requested label Jul 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

5 participants