iOS 5 create custom UIButton reusable component with .XIB -


i'm newbie in ios development , i'm working in projecte uses ios5 , storyboarding. create reusable component, button, custom view (inside button there images , labels, big button), create of them in same view of storyboard. i've created xib file (itemclothes.xib) uibutton , inside of uiimagesviews , uilabel. i've created subclass of uibutton (uiitemclothes.h , uiitemclothes.m), properties uiimageviews , uilabel components.

uiitemclothes.h

#import <uikit/uikit.h> #import "scclothes.h" @interface uiitemclothes : uibutton @property (nonatomic, strong) iboutlet uiimageview *imageclothes; @property (nonatomic, strong) iboutlet uiactivityindicatorview *loadingimage; @property (nonatomic, strong) iboutlet uiimageview *seasoniconclothes; @property (nonatomic, strong) iboutlet uiimageview *categoryiconclothes; @property (nonatomic, strong) nsstring *idclothes; @property (strong, nonatomic) iboutlet uilabel *lblprova; @end 

uiitemclothes.m

#import "uiitemclothes.h" @implementation uiitemclothes @synthesize imageclothes = _imageclothes; @synthesize loadingimage = _loadingimage; @synthesize seasoniconclothes = _seasoniconclothes; @synthesize categoryiconclothes = _categoryiconclothes; @synthesize idclothes = _idclothes; @synthesize lblprova = _lblprova; - (id)initwithframe:(cgrect)frame { self = [super initwithframe:frame]; if (self) { // initialization code [self addsubview:[[[nsbundle mainbundle] loadnibnamed:@"itemclothes" owner:self options:nil] objectatindex:0]]; } return self; } @end 

then in .xib file i've set class of uibutton uiitemclothes, , make relationships between xib's ui components , class properties.

so, after that, in storyboard, in viewcontroller of 1 view i've written code:

uiitemclothes *item = [[uiitemclothes alloc] initwithframe:cgrectmake(0.0, 0.0, 200.0, 200.0)]; item.lblprova.text = @"test!"; [item.categoryiconclothes setimage:iconcategory]; item.seasoniconclothes.image = iconseason; [cell addsubview:item]; 

as see, component inside tableviewcell, , idea put more components (uiitemclothes) inside of it.

the problem component drawed outlet set in code above.

can me? thanks!

well, problem has been resolved... instead of having custom subclass of uibutton, there needed viewcontroller outlets. in other viewcontroller (storyboard) initialized new viewcontroller


Comments

Popular posts from this blog

javascript - backbone.js Collection.add() doesn't `construct` (`initialize`) an object -

php - Get uncommon values from two or more arrays -

Adding duplicate array rows in Php -