问题描述
我在带有大标题和UIRefreshControl的导航控制器中嵌入了一个控制器.当我在tableView上进行拉动刷新时,活动指示器的动画会出现故障.
我不知道我的代码是否有不良行为?
tableView.refreshControl = UIRefreshControl()tableView.refreshControl?.addTarget(自己,操作:#selector(downloadData),用于:.valueChanged)
如果将导航栏的半透明外观设置为false,则需要在视图控制器中包含以下代码以处理不透明的栏.同样,在情节提要中,tableView必须将顶级约束扩展到Superview.不知何故,我不知道为什么没有适当的文档指出,但似乎可以解决故障动画.
self.extendedLayoutIncludesOpaqueBars = true
此外,在@ Ravi Raja Jangid发布的链接的帮助下,我发现此设置目前运行良好.我不确定这是因为tableview现在已附加到Superview(扩展状态栏),还是因为iOS版本升级已解决了错误问题.
I have a controller embedded in a navigation controller with Large Titles and a UIRefreshControl. When I pull-to-refresh on my tableView, the animation of the activity indicator is very glitchy.
I don't know if I have a bad behaviour in my code ?
tableView.refreshControl = UIRefreshControl()
tableView.refreshControl?.addTarget(self, action: #selector(downloadData), for: .valueChanged)
If your have set your navigation bar translucency appearance to false, then you need to include the following code in your view controller to handle opaque bars. Also, in storyboard, the tableView has to have the top constraint extended to the Superview. Somehow, I don't know why there's no proper documentation indicating as such but it seems to resolve the glitchy animation.
self.extendedLayoutIncludesOpaqueBars = true
Adding into this, I find this setup to be working well at the moment with the help of the link that @ Ravi Raja Jangid posted. I'm not sure if it's because tableview is now attached to the Superview (extending status bar) or has the iOS version upgrade fixed the buggy issue.
SearchController:
private lazy var searchController: UISearchController = {
let searchController = UISearchController(searchResultsController: nil)
searchController.searchResultsUpdater = self
searchController.obscuresBackgroundDuringPresentation = false
searchController.hidesNavigationBarDuringPresentation = false
self.definesPresentationContext = false
return searchController
}()
viewDidLoad()
self.navigationItem.hidesSearchBarWhenScrolling = false
self.navigationItem.searchController = self.searchController
self.navigationController?.navigationBar.isTranslucent = false
self.extendedLayoutIncludesOpaqueBars = true
Storyboard Setup:
这篇关于UIRefreshControl的闪烁动画,带有大标题或导航栏中的搜索栏的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!