我有一个 UISearchbar,它的键盘上的返回键是灰色的,除非我在搜索栏中输入文本。如何允许它出现在没有文字上?如果那不可能,如果搜索栏中没有文本,我如何返回到我的视图?
继承人一些代码:
- (BOOL)searchBarShouldBeginEditing:(UISearchBar *)searchBar
{
touchtoCancel = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height-211)];
[touchtoCancel addTarget:self
action:@selector(DidPressCancelSearch:)
forControlEvents:UIControlEventTouchUpInside];
[self.search setFrame:CGRectMake(self.search.frame.origin.x, self.search.frame.origin.y-210,
self.search.frame.size.width, self.search.frame.size.height)];
return YES;
}
-(IBAction)DidPressCancelSearch:(id)sender
{
[search resignFirstResponder];
}