开发者

How can I add an UISerachBar to an UIToolBar?

I try now something like this:

UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIViewController *searchBarContainer = [[UIViewController alloc] initWithFrame:searchBar.frame];
[searchBarContainer addSubview:searchBar];

NSArray* buttons = [NSArray arrayWithObject开发者_开发技巧s:fixed, searchBarContainer, nil];

[detailToolbar setItems:buttons animated:NO];


UISearchBar *searchBar = [[UISearchBar alloc] initWithFrame:CGRectMake(0, 0, 320, 44)];
UIBarButtonItem  * searchBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:searchBar];

UIToolbar  * searchToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0,0+20,[self view].bounds.size.width,32)];

[searchToolbar setItems:[NSArray arrayWithObjects:searchBarButtonItem,homeButtonItem, nil] animated:YES];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜