Use a custom view under Xib, because many times it might be fortunate to have a view, and then populate the view with controls, but you need to rewrite a lot of useless
Code, and very easy to make mistakes do not say, but also a good workload, using xib words, minutes to fix a view, words do not say, the steps are as follows:
1, first create a view
2, create a xib
3, the class of "File ' Owner" is inherited as: MyView (that is, the custom created view class)
4, then select, such as: In the fourth step, class inherits as: MyView,
5, then, you can happily drag the control on the xib and drag it into the. h file:
6, note that at this time, you must be in the "File's Owner" Inside, the Postcode attribute chat table connection point off, here can not exist such a connection,
7, for example, in the view to connect the connection, you can
8, then load the controller inside, the code is as follows:
Nsarray *nibview = [[NSBundle Mainbundle] loadnibnamed:@ "xib name "*backview = [Nibview Objectatindex:0= frame;[ Self Addsubview:backview];
Finally, in the controller to write what you want to do, call the time, with the local instantiation of the MyView directly invoke the control, you can!
Example code:
// add push-to-flow trigger button [_hview.actionbtn settitle:@ " push stream end/play end " forstate:uicontrolstatenormal]; [_hview.actionbtn settitle: @" Pause Playback " forstate:uicontrolstateselected]; [_hview.actionbtn addtarget:self Action: @selector (Actionbutton:) forcontrolevents:uicontroleventtouchupinside]; // Add play-side trigger button [_hview.playbtn addtarget:self Action: @selector (Playclick:) Forcontrolevents:uicontroleventtouchupinside];
iOS development--Xib associated Custom View