Odr*_*kir 7 objective-c uisearchbar ios ios7
不知道为什么,我在iOS 7中的搜索栏正在留下一个合适的空间.它在iOS 6中没问题.
我知道它与部分索引有关,因为如果我删除它,空间就会消失,但我不知道如何修复它.有什么想法吗?

将UISearchBar嵌入到UIView中,然后将其添加为tableHeaderView.在故事板中以这种方式构建它对我有用.我猜iOS在tableHeaderView中调整了UISearchBar的大小,但是只留下了一个基本的UIView(并且没有在里面查看它).
你可能还想让部分索引透明,我做了:
[[UITableView appearance] setSectionIndexBackgroundColor:[UIColor clearColor]];
[[UITableView appearance] setSectionIndexTrackingBackgroundColor:[UIColor clearColor]];
Run Code Online (Sandbox Code Playgroud)
在出现更好的答案之前,我只需手动更改搜索栏的框架,如下所示:
- (void)viewDidLayoutSubviews {
[super viewDidLayoutSubviews];
CGRect barFrame = self.searchBar.frame;
barFrame.size.width = self.view.bounds.size.width;
self.searchBar.frame = barFrame;
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
5289 次 |
| 最近记录: |