小编Vil*_*zed的帖子

iOS 11大标题导航栏快照而不是平滑过渡

我正面临一个问题,当在UIViewController内部嵌入的UITableView上滚动时,大标题导航栏会突然崩溃.问题似乎只发生在屏幕上向上滚动时.当在屏幕上向下滚动时,标题会平滑过渡到再次变大,但反之则不然.

如果使用UITableViewController,则不会发生此问题.

这是在UITableViewController内滚动时的正常预期行为.

UIViewController内的iOS 11 UITableView(滚动时突然转换)

当在UIViewController中使用UITableView时,这是一个破碎的,突然的转换.

iOS 11 UITableViewController(正确转换)

以下是破坏实现的代码:

class ViewController: UIViewController, UITableViewDataSource, UITableViewDelegate {

    func numberOfSections(in tableView: UITableView) -> Int {
        return 1
    }

    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 12
    }

    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        let cell = tableView.dequeueReusableCell(withIdentifier: "Basic", for: indexPath)

        cell.textLabel?.text = "Title \(indexPath.row)"

        return cell
    }

}
Run Code Online (Sandbox Code Playgroud)

导航栏优先选中大标题,导航项将大标题设置为自动.

上面两个示例的代码和配置完全相同,除了一个是UITableViewController与UIViewController内的UITableView.

我还观察到,如果UITableView的内容不超过视图的高度,则不会发生破坏的行为.但是,一旦有更多的细胞可以放在屏幕上,它就会破裂.

不知道我做错了什么或者这是iOS 11的错误吗?

xcode uitableview uiviewcontroller swift ios11

25
推荐指数
3
解决办法
8766
查看次数

标签 统计

ios11 ×1

swift ×1

uitableview ×1

uiviewcontroller ×1

xcode ×1