IOS 7 – Display number of search results in the search bar

I’m searching for a way to add a UILabel to an UISearchBar in Front of the Searchfield.

I tried to add a UILabel like that:

- (void)searchDisplayControllerWillBeginSearch:(UISearchDisplayController *)controller
{
  self.searchDisplayController.searchBar.showsCancelButton = YES;

  UILabel *searchResultCount = [[UILabel alloc] initWithFrame:CGRectMake(8, 8, 50, 28)];
  searchResultCount.text = @"357"; //Itemscount of Searchresult

  [self.searchDisplayController.searchBar addSubview:searchResultCount];
}

The Result looks like that ==> http://i.stack.imgur.com/x3sel.png

How can i get this work ? It should be

[356] [Searchfield] [Cancel]

Thanks for any advise

You can adjust search text position. Just add:

self.searchDisplayController.searchBar.searchTextPositionAdjustment = UIOffsetMake(65., 0.);
Hello, buddy!责编内容来自:Hello, buddy! (源链) | 更多关于

阅读提示:酷辣虫无法对本内容的真实性提供任何保证,请自行验证并承担相关的风险与后果!
本站遵循[CC BY-NC-SA 4.0]。如您有版权、意见投诉等问题,请通过eMail联系我们处理。
酷辣虫 » 移动开发 » IOS 7 – Display number of search results in the search bar

喜欢 (0)or分享给?

专业 x 专注 x 聚合 x 分享 CC BY-NC-SA 4.0

使用声明 | 英豪名录