de.*_*de. 12 uitableview uikit uirefreshcontrol uisearchcontroller ios11
我试图UIRefreshControl在表视图上使用新的searchControllerAPI navigationItem.
现在,当我设置hidesSearchBarWhenScrolling"下拉刷新"动画不再显示时,刷新控件只是在某一点弹出.
它似乎是UIKit中的一个错误(与每年相同的程序).有没有人找到这个解决方案?
要重现此问题,请将其添加到全新的iOS 11"主/详细信息"示例项目中:
- (void)viewDidLoad {
// [setup code here]
self.refreshControl = [UIRefreshControl new];
self.navigationItem.searchController = [[UISearchController alloc] initWithSearchResultsController:nil];
self.navigationItem.hidesSearchBarWhenScrolling = NO; // <-- setting this causes jumpy UI
}
Run Code Online (Sandbox Code Playgroud)
我刚刚经历了同样的问题。它看起来确实像是 UIKit 中的一个错误。这绝对是值得提交雷达的东西。
我发现了一个非常hacky的方法来缓解它:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
//Fixes a bug in UIKit where the refresh control is broken when `hidesSearchBarWhenScrolling` is NO.
if (@available(iOS 11.0, *)) {
self.navigationItem.hidesSearchBarWhenScrolling = scrollView.contentOffset.y < -scrollView.adjustedContentInset.top;
}
}
Run Code Online (Sandbox Code Playgroud)
基本上这里发生的事情是,每当滚动视图滚动到顶部(刷新控件将变得可见)时,这段代码就会变成hidesSearchBarWhenScrolling到YES. 一旦用户再次向下滚动,它将被设置回NO并且搜索栏将继续保持可见。
希望苹果能够在未来的 iOS 版本中修复这个问题,但对于当前的发布版本来说,这可能是必须要做的。
| 归档时间: |
|
| 查看次数: |
838 次 |
| 最近记录: |