【发布时间】:2010-08-10 08:59:55
【问题描述】:
我看过 Apple 的示例“TableSearch”,当触摸它的范围按钮时,它会出现在搜索栏下方。 http://developer.apple.com/iphone/library/samplecode/TableSearch/Introduction/Intro.html
但是当我自己制作时,起初它看起来不错,但当我触摸它时,它看起来很丑,范围按钮和搜索栏显示在同一行,如下所示: http://cl.ly/BN9
我需要做什么才能使它像 iPad 中的“TableSearch”示例?
我在 IB 中做所有事情,并尝试从控制器以编程方式修改搜索栏:
- (void)viewDidLoad {
[super viewDidLoad];
self.tableView.rowHeight = 88.0f;
self.tableView.contentOffset = CGPointMake(0, self.searchDisplayController.searchBar.frame.size.height);
self.searchDisplayController.searchResultsTableView.rowHeight = self.tableView.rowHeight;
//BELOW DID NOT WORK:
CGRect b = self.searchDisplayController.searchBar.bounds;
self.searchDisplayController.searchBar.bounds = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
b = self.searchDisplayController.searchBar.frame;
self.searchDisplayController.searchBar.frame = CGRectMake(b.origin.x, b.origin.y, b.size.width, self.tableView.rowHeight);
//BELOW WORKS PERFECT BUT IS A PRIVATE METHOD, HENCE I AM NOT SUPPOSED TO USE IT
//[self.searchDisplayController.searchBar setCombinesLandscapeBars:NO];
}
提前致谢。
【问题讨论】:
标签: ipad uisearchbar uisearchdisplaycontroller