问题:
在iOS7中,在navigationtionBar上面添加searchBar的时候,设置searchBar的showCancelButton属性为Yes的时候,在iOS7还是不会显示取消按钮。
解决方案:
解决方法很简单,就是自己手动添加一个取消按钮。实现方法如下所示:
UIBarButtonItem *cancelButton = [[UIBarButtomItem alloc] initWithTitle: @"取消" style:UIBarButtonItemStylePlain target:self action:@selector(clickCancleButton)];
NSDictionary *fontAttr = @{NSFontAttributeName:[UIFont systemFontOfSize: 16], NSForgroundColorAttributeName: [UIColor blue]};
[cancelButton setTitleTextAttribute:fontAttr forState: UIControlStateNormal];
self.navigationBar.rightBarButtonItem = cancelButton;