iphone - Issue Subclassing UIView -
i've created own custom view, own header , main file , corresponding nib (.xib):
the header file
#import <foundation/foundation.h> #import <uikit/uikit.h>  @interface pointsbarview : uiview  {     iboutlet uiview *pointsbarview;      iboutlet uiview *pointscounterview;      iboutlet uilabel *pointstotallabel;     uiimageview *handimageview;     uiimageview *powerbaroutlineimageview; }  @property (nonatomic, retain) iboutlet uiview *pointscounterview;    @property (nonatomic, retain) iboutlet uiview *pointsbarview; @property (nonatomic, retain) iboutlet uilabel *pointstotallabel; @property (nonatomic, retain) iboutlet uiimageview *handimageview; @property (nonatomic, retain) iboutlet uiimageview *powerbaroutlineimageview;  @end i'm synthesizing in main, , in uiviewcontroller class i'm trying load view. set property:
@property (nonatomic, assign) iboutlet pointsbarview *pointsbarview; and adding so:
nsarray* nibviews =  [[nsbundle mainbundle] loadnibnamed:@"pointsbarview" owner:self options:nil];     pointsbarview = [nibviews objectatindex: 0];          [[self view] addsubview:pointsbarview]; how access subviews within nib?  need embedded within pointsbarview?  (pointsbarview references main view of nib, , other views within pointsbarview).  should each separate piece of nib , need call addsubview each 1 display?
i should note if not connect of properties in pointsbarview, view displays fine code in uiviewcontroller class.  want able interact each view , change properties accordingly.  great!
the general rule of thumb is: if load code, connect in code.
conversely:
if instantiate in ib, can connect outlets , actions in ib.
here loading view in code, have manually connect them.
if want able connect stuff in ib add uiview in ib , change subclass pointsbarview. ib magically read pointsbarview.h file , should able connect outlets, targets , actions.
Comments
Post a Comment