2

I'm working in xcode version 6.1. I've just drag and drop the UISearchBar in my UIViewController...Now i just copied and paste this storyboard for iPad device..But for the iPhone device i can see the cancel button,,but for the Ipad device the cancel button didn't appear..

Below is the code

 [searchBar setPlaceholder:AMLocalizedString(@"Search people", nil)];
 id barButtonAppearanceInSearchBar = [UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil];
 [barButtonAppearanceInSearchBar setTitle:AMLocalizedString(@"Cancel",nil)];

Can anyone help me!!!!!

Rishil Patel
  • 1,977
  • 3
  • 14
  • 30
Sonu
  • 937
  • 1
  • 10
  • 39

2 Answers2

0

Try to use a rightBarButtonItem instead

Ailix
  • 63
  • 1
  • 6
-2

I understand that you are trying to embed the UISearchBar in the NavigationBar/Toolbar; if so, here is a solution to do that programmatically: iOS7 when UIsearchbar added in UINavigationBar not showing cancel button

UISearchBar *searchBar = [UISearchBar new];
searchBar.showsCancelButton = YES;
[searchBar sizeToFit];
UIView *barWrapper = [[UIView alloc]initWithFrame:searchBar.bounds];
[barWrapper addSubview:searchBar];
self.navigationItem.titleView = barWrapper;
Community
  • 1
  • 1
IronMyke
  • 1
  • 2