【问题标题】:Remove or override the "Clear Button" on UISearchDisplayController in a UIPopoverController on iPad?在 iPad 上的 UIPopoverController 中删除或覆盖 UISearchDisplayController 上的“清除按钮”?
【发布时间】:2012-03-15 00:00:16
【问题描述】:

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

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

【问题讨论】:

    标签: ios ipad


    【解决方案1】:

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

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

    祝你好运。

    【讨论】:

    • 抱歉实际上是指清除按钮而不是取消按钮。这解释了搜索字段右侧的小按钮。我编辑了问题以说出清除按钮。但感谢您抽出宝贵时间。
    • 是的,我对此按钮的回答:)
    • 为清晰起见更新了图片;-)
    • 好的,你为什么不让你的 popOver 显示结果然后你就可以完全控制改变你想要的?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-10-28
    • 2012-12-28
    • 2011-04-22
    • 2013-12-26
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多