Objective c UIBarButtonims中嵌入的UISearchBar(仅在iPad文档中提供)?
我正试图将UISearchBar插入到我的TableView工具栏中,但由于此错误,它无法构建我的应用程序(iOS5.1)Objective c UIBarButtonims中嵌入的UISearchBar(仅在iPad文档中提供)?,objective-c,ios5,xcode4.5,uisearchbar,Objective C,Ios5,Xcode4.5,Uisearchbar,我正试图将UISearchBar插入到我的TableView工具栏中,但由于此错误,它无法构建我的应用程序(iOS5.1) UISearchBar embedded in UIBarButtonItems (Only available in iPad documents) 我真的搞不懂 有什么想法吗?也就是说,您可以创建自己的视图,使其外观和工作方式类似于允许使用UISearchBar的UIToolbar 解决方案是使用导航栏而不是工具栏。将搜索栏设置为导航栏的标题视图 或Yu可以通过编
UISearchBar embedded in UIBarButtonItems (Only available in iPad documents)
我真的搞不懂
有什么想法吗?也就是说,您可以创建自己的视图,使其外观和工作方式类似于允许使用
UISearchBar的UIToolbar
解决方案是使用导航栏而不是工具栏。将搜索栏设置为导航栏的标题视图
或Yu可以通过编程方式添加它
self.searchBar.frame = CGRectMake(70, 3, 230, 44);
UIToolbar * searchToolbar = [[UIToolbar alloc]initWithFrame:CGRectMake(0,0+20,[self view].bounds.size.width,52)];
UIBarButtonItem *flexibleSpace = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemFlexibleSpace target:nil action:nil];
UIBarButtonItem *infoButtonItem=[[UIBarButtonItem alloc]initWithTitle:@"Update" style:UIBarButtonItemStyleBordered target:self action:@selector(infoButtonClicked)];
UIBarButtonItem * searchBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:self.searchBar];
[searchToolbar setItems:[NSArray arrayWithObjects:flexibleSpace,infoButtonItem,searchBarButtonItem, nil] animated:YES];
[self.view addSubview:searchToolbar];
苹果在Xcode 8.2中修复了这个问题。我想他们以前禁用过它,因为在iOS 8.0之前的iOS上不允许使用popover,而工具栏中的搜索栏意味着popover将被最多使用