UISearchBar inputAccessoryView

旧街凉风 提交于 2019-12-21 05:31:09

问题


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


回答1:


Edit: As is mentioned in the comments below, this is no longer an issue post iOS 6. See the UISearchBar documentation here.


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



回答2:


As of iOS 6.0 the inputAccessoryView is now readwrite!

@property (nonatomic, readwrite, retain) UIView *inputAccessoryView;
                      ^^^^^^^^^


来源:https://stackoverflow.com/questions/7058133/uisearchbar-inputaccessoryview

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!