【发布时间】:2012-03-15 00:00:16
【问题描述】:
在 iPad 中将 UISearchDisplayController 与 UISearchBar 一起使用时,它会显示在 UIPopoverController 中。我想覆盖图像上显示的清除按钮以进行进一步修复。如果这是不可能的,我该如何删除清除按钮?
【问题讨论】:
在 iPad 中将 UISearchDisplayController 与 UISearchBar 一起使用时,它会显示在 UIPopoverController 中。我想覆盖图像上显示的清除按钮以进行进一步修复。如果这是不可能的,我该如何删除清除按钮?
【问题讨论】:
我做过一次..我用自定义按钮替换清除按钮以进行自定义操作..请检查此
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];
祝你好运。
【讨论】: