【发布时间】:2014-06-08 21:33:10
【问题描述】:
我在更改搜索栏取消按钮的文本时遇到问题。
查看我的代码:
- (void)searchBarTextDidBeginEditing:(UISearchBar *)searchBar
{
[_srBar setShowsCancelButton:YES animated:YES];
UIButton *cancelButton = nil;
for (UIView *subView in searchBar.subviews) {
if ([subView isKindOfClass:NSClassFromString(@"UIButton")]) {
cancelButton = (UIButton*)subView;
}
}
[cancelButton setTitle:@"Annuller" forState:UIControlStateNormal];
}
我也已经尝试过其他选项
iOS Change the title of cancel button in UISearchBar iOS - Customizing Cancel button of UISearchBar
在这个例子中我的代码没有调用方法
How to change the default text of Cancel Button which appears in the UISearchBar +iPhone
我的风景
#import <UIKit/UIKit.h>
@interface favorito : UIViewController<UISearchControllerDelegate, UISearchDisplayDelegate, UISearchBarDelegate,UITableViewDelegate,UITableViewDataSource>
@end
【问题讨论】:
标签: ios uiviewcontroller uibutton uisearchbar