1

在 iPhone SDK 中是否有任何简单的方法来包含像 iPod 应用程序或联系人应用程序中的搜索栏?(它们的行为和外观与通常的 UISearchBars 不同......)

-- 瑞

4

2 回答 2

2

查看 UISearchDisplayController。它处理搜索栏的重新定位、屏幕变灰等等等等。

UIViewController 有一个 UISearchDisplayController 属性,所以很容易连接。还有 TableSearch 示例代码。

于 2010-03-16T19:43:44.327 回答
0

这会在表格视图中添加一个搜索栏作为标题视图。这意味着它会随着表格视图滚动:

- (void) viewDidLoad
{
    [super viewDidLoad];
    UISearchBar* searchBar = [[UISearchBar alloc] initWithFrame: CGRectMake(0, 0, 320, 45)];
    if (searchBar != nil) {
        // Your UISearchBar specifics here
        self.tableView.tableHeaderView = searchBar;
    }
}
于 2010-03-16T19:26:54.477 回答