删除或覆盖“清除按钮”在iPad上的UIPopoverController中的UISearchDisplayController上? [英] Remove or override the "Clear Button" on UISearchDisplayController in a UIPopoverController on iPad?

查看:78
本文介绍了删除或覆盖“清除按钮”在iPad上的UIPopoverController中的UISearchDisplayController上?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

When using UISearchDisplayController with a UISearchBar in iPad it is displayed in a UIPopoverController. I would like to override the clear button as shown on the image to make further fixes. If that is not possible, how can I remove the clear button?

清除按钮http://desmond.imageshack.us/Himg692/scaled.php?server=692&filename=537870177.png&res=medium

推荐答案

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

i did that once .. i replace the clear button with a custom button to make a custom action .. please check this

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];

祝你好运。

这篇关于删除或覆盖“清除按钮”在iPad上的UIPopoverController中的UISearchDisplayController上?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆