UITable first section contains a

UITable first section contains a

能否归途做我良人 发布于 2021-11-25 字数 765 浏览 871 回复 3 原文

So, I can provide a picture in a bit if that would help clarify.

I currently have a UITableView with alot of rows. The first row of the table is a search bar. Great, works fine.

I've just added "plain" indexes, alphabetic headings before each section displayed in the table. I've also added right most index for jumping quickly to any section.

However, since the UISearchBar is part of the of the table (the first element) when the UISearchBar is drawn, it pushes the UISearchBar over a bit, squishing it. It looks silly. One option is not make the UISearchBar part of the table, but I have no where else to put it.

Any idea how to get the right most index to sit over the UISearchBar?


  • sk

如果你对这篇文章有疑问,欢迎到本站 社区 发帖提问或使用手Q扫描下方二维码加群参与讨论,获取更多帮助。



需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。


べ映画 2022-06-07 3 楼

I am not sure what you mean by "pushing it over a bit" but you can adjust the height of a row by usign the delegate method

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath

That might get you a bit more room to play around with. You can also look areound as to where the cell is drawing the UISearchBar in relation to itself and perhaps pretty that up as well.

However I would also recommend going with a ViewController with a tableView and searchView. also if you are a 3.0 developer there could be some new search UI that you may want to look at.

水波映月 2022-06-07 2 楼

Have you tried to put it into the tableView.tableHeaderView?

半窗疏影 2022-06-07 1 楼

I usually end up starting out with a UITableViewController subclass, then in the end just turning it into a plain UIViewController subclass so the UITableView is only a part of a more involved view. Just create a view with the search bar at the top, and the table taking up the rest of the space.