开发者

UITableView search bar?

is there any easy way in the iPhone SDK to include search bars like those in the iPod app or in the Contacts app? (They behave and look unlike the usual UISearchBar开发者_如何转开发s ...)

-- Ry


Check out UISearchDisplayController. It handles the repositioning of the search bar, the graying of the screen, etc, etc, etc.

UIViewController has a UISearchDisplayController property, so it's pretty easy to hook up. There's also the TableSearch sample code.


This adds a search bar to a table view as the header view. This means that it scrolls with the table view:

- (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;
    }
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜