【问题标题】:iOS - ObjectiveC: Reload UITableView with pull to SearchiOS - ObjectiveC:重新加载 UITableView 并拉到搜索
【发布时间】:2014-12-19 15:51:57
【问题描述】:

我有一个UITableView,顶部有一个自定义search bar(标题)。在viewDidLoad 上,我通过设置mytableView.content.offset.y = mySearchBar.frame.size.height 隐藏搜索栏。我还有一个重新加载按钮,女巫重新加载整个视图。我的问题是每次重新加载时,tableView 在 content.offset 更改时都会“颠簸”。我需要重新加载,而不仅仅是更新 tableView 单元格。任何想法如何使用隐藏的搜索栏重新加载我的 tableView 并管理“碰撞”问题?谢谢!

查看层次结构

  • 表格视图
    • 搜索栏
    • 标题
    • 细胞

【问题讨论】:

  • "我有一个 UITableView,上面有一个自定义搜索栏。" - 你能解释一下这是什么意思吗?在表头的顶部?在整个 tableview 之上?在桌面视图上方?

标签: ios objective-c uitableview reload searchbar


【解决方案1】:

通过将两个视图都放在 UITableView 上,我能够实现类似的效果。

RefreshView *view = [RefreshView refreshView];
view.frame = CGRectMake(0.0f, 0.0f - self.tableView.bounds.size.height, self.view.frame.size.width, self.tableView.bounds.size.height);
[self.tableView addSubview:view];

加载开始时我会这样做:

UIEdgeInsets inset = scrollView.contentInset;
inset.top = 110.0f; //height of my refresh view
scrollView.contentInset = inset;

完成后:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3];
UIEdgeInsets inset = scrollView.contentInset;
inset.top = 0.0f;
scrollView.contentInset = inset;
[UIView commitAnimations];

这样,即使表格为空,视图的行为也很好,并且始终遵循 contentOffset。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-26
    • 1970-01-01
    相关资源
    最近更新 更多