ios 自定义规则

UISearchBar inputAccessoryView
The UISearchBar seems to have the inputAccessoryView as a readOnly property. How do I set it with my own customToolbar ?

The UIResponder (of which UISearchBar is an indirect subclass of) class documentation details a way to accomplish this:

Subclasses that want to attach custom controls to either a system-supplied input view (such as the keyboard) or a custom input view (one you provide in the inputView property) should redeclare this property as readwrite and use it to manage their custom accessory view. When the receiver subsequently becomes the first responder, the responder infrastructure attaches the view to the appropriate input view before displaying it.

e.x.

@interface CustomSearchBar : UISearchBar
@property (readwrite, retain) UIView *inputAccessoryView;
@end


意思是说:如果你想自定义一个类,并且想把这个类只读的控件变成可写的,那就要重写这个控件

猜你喜欢

转载自zl4393753.iteye.com/blog/1757169