滚动 tableView 时保持搜索栏固定位置 [英] Keep search bar fixed position while scrolling tableView

查看:34
本文介绍了滚动 tableView 时保持搜索栏固定位置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在滚动表格视图时将我在 Xcode 4.3.3 中创建的 uiSearch 栏固定在顶部?有什么想法吗?

How can i keep the uiSearch bar i created in Xcode 4.3.3 fixed on top while scrolling the table view? Any thoughts?

推荐答案

如果您已使用界面构建器添加搜索栏,请确保它没有添加为 tableview 的子视图(这会使搜索栏成为表格的一部分,与表格一起滚动).查看下面的链接,避免它.此链接显示搜索栏如何成为表格的子视图.这不是你想要的.只需将搜索栏拖到您的界面构建器中的表格视图之外,使其成为视图的一部分.

EDITED: If u have used the Interface builder to add the search bar, make sure that it is not added as the subview of the tableview (this makes the search bar as a part of the table, which scrolls along with the table). Checkout the link below, and avoid it. This link shows how a search bar becomes a subview of the table. This is not what u want. Just drag the search bar outside of the Table view in ur interface builder, so that it becomes a part of the view.

我添加了第二张图片来展示您如何找到问题的解决方案.

I have added second image to show how u can find the solution to ur problem.

如果你想以编程方式添加搜索栏,那么只需将其添加为-

If u want to add the search bar programatically, then just add it as-

[self.view addSubview:mySearchBar];

相应地设置此搜索栏的框架.

Set the frame of this search bar accordingly.

这篇关于滚动 tableView 时保持搜索栏固定位置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆