0
在iPad中使用UISearchDisplayController和UISearchBar時,它將顯示在UIPopoverController中。我想重寫圖像上顯示的清除按鈕以進一步修復。如果這是不可能的,我怎樣才能刪除清除按鈕?刪除或覆蓋iPad上UIPopoverController的UISearchDisplayController上的「清除按鈕」?
在iPad中使用UISearchDisplayController和UISearchBar時,它將顯示在UIPopoverController中。我想重寫圖像上顯示的清除按鈕以進一步修復。如果這是不可能的,我怎樣才能刪除清除按鈕?刪除或覆蓋iPad上UIPopoverController的UISearchDisplayController上的「清除按鈕」?
我這樣做一次..我用自定義按鈕進行自定義操作更換清除按鈕..請檢查此
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];
好運。
對不起,其實意味着清除按鈕不是取消按鈕。 這解釋了搜索字段右側的小按鈕。 我編輯了問題來說清楚按鈕。但感謝您花時間。 – 2012-03-14 15:16:09
耶和我的答案爲這個按鈕:) – 2012-03-14 15:18:26
更新了圖片的清晰度;-) – 2012-03-14 15:34:22