gpt4 book ai didi

iOS 11 beginRefreshing 以编程方式在导航栏上使用大标题

转载 作者:IT王子 更新时间:2023-10-29 05:44:56 25 4
gpt4 key购买 nike

在 iOS 10 中,我曾经像这样以编程方式开始刷新 UIRefreshControl(以编程方式显示刷新控件):

self.tableView.setContentOffset(CGPoint(x: 0, y: - self.refreshControl.bounds.height), animated: false)
self.refreshControl.beginRefreshing()

但现在在 iOS 11 中,该代码不起作用,它只会弄乱 UINavigationController 的大小,并且 UIRefreshControl 不会出现。

如何使用 iOS 11 中的 prefersLargeTitles 开始以编程方式刷新 UIRefreshControl(以编程方式显示刷新控件)?

最佳答案

UIRefreshControl 旨在与 UITableViewController 一起使用。在不在 UITableViewController 中的 UITableView 上使用它会导致未定义的行为。

虽然让您的 View Controller 成为 UITableViewController 的子类并不总是可行的,但您始终可以拥有一个添加了 UITableViewControllerUIViewController 子类> 作为 child 的子类。这样您就可以使用 UIRefreshControlUITableViewController 提供的其他优点,同时仍然可以在需要时使用 UIViewController 子类。

关于iOS 11 beginRefreshing 以编程方式在导航栏上使用大标题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46351923/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com