删除或覆盖"清除按钮"在iPad上的UIPopoverController中的UISearchDisplayController上?

时间:2012-03-14 15:05:40

标签: ios ipad

在iPad中使用带有UISearchBar的UISearchDisplayController时,它会显示在UIPopoverController中。我想覆盖图像上显示的清除按钮以进一步修复。如果不可能,我该如何删除清除按钮?

Clear button http://desmond.imageshack.us/Himg692/scaled.php?server=692&filename=537870177.png&res=medium

1 个答案:

答案 0 :(得分:0)

我做了一次..我用自定义按钮替换了清除按钮以进行自定义操作..请检查此

UISearchBar *searchBar = yourSearchController.searchBar;
UITextField *searchtextfield = [searchBar.subviews objectAtIndex:1];
UIButton *cButton = [UIButton buttonWithType:UIButtonTypeCustom];
cButton.frame = CGRectMake(0, 0, 20 , 20);
cButton.backgroundColor = [UIColor clearColor];
[cButton setImage:[UIImage newImageFromResource:@"yourButtonImage"] forState:UIControlStateNormal];//your button image.
cButton.contentMode = UIViewContentModeScaleToFill;
[cButton addTarget:self action:@selector(customButtonPressed) forControlEvents:UIControlEventTouchUpInside];//This is the custom event
[searchtextfield setRightView:cButton];
[searchtextfield setRightViewMode:UITextFieldViewModeAlways];
祝你好运。