//Set all cancel buttons in search bars to "Done"
id searchBarButton = [UIBarButtonItem appearanceWhenContainedIn:[UISearchBar class], nil];
if([[[UIDevice currentDevice] systemVersion] floatValue] < 7) {
[searchBarButton setTitle:@"Done"];
} else {
//Can't do anything here or i get EXC_BAD_ACCESS
}
viewDidLoad
仅在 iOS 7 Gold Master 和更高版本上调用时,这会给出 EXC_BAD_ACCESS 。iOS 7 beta 6 及更早版本都可以。
在 iOS 7 中是否有其他方法可以做到这一点?
NSLog("%@", searchBarButton)
结果在iOS7上:
2013-10-01 16:14:25.972 MP Staging[12293:a0b] <_UIBarItemAppearance:0x1aaf72d0> <Customizable class: UIBarButtonItem> when contained in (
UISearchBar
) with invocations (null)>
这在 iOS 6 上
<_UIBarItemAppearance: 0x1c671aa0>