UITextField * textField= self.textField;
textField.background = [UIImage resizeableImageWithCapInsets2:UIEdgeInsetsMake(0, 7, 0, 7) withName:@"Search-Field"];
简单的代码。为什么此代码不再适用于7.1?
2014-03-13 09:31:02.099 isikota[179:60b] -[BGSearchBar setBackground:]: unrecognized selector sent to instance 0x17566b20
2014-03-13 09:32:17.720 isikota[179:60b] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[BGSearchBar setBackground:]: unrecognized selector sent to instance 0x17566b20'
这没有意义。显然,背景是文本框
的财产,我发现这个问题是我用这个:
-(UITextField *) textField
{
UIView * textFieldView = [self findASubViewWithProtocol:@protocol(UITextInputTraits)];
return (UITextField *)textFieldView;
}
这似乎不再得到的UISearchBar一个文本框的方式。那么怎么做?
我认为这个问题是因为7.1 [UISearchBar conforms to UITextInputTraits]
而且我不知道为什么
return (UITextField *)textFieldView;
不返回运行时错误,因为现在textFieldView不再的UITextField
的一个子类
错误说'textField'是一个'BGSearchBar'。 – Pang
我知道。看起来像7.1 UIView * textFieldView = [self findASubViewWithProtocol:@protocol(UITextInputTraits)];返回uisearchbar。 –