iphone - create uibutton subclass -


i tried subclass uibutton include activity indicator, when use initwithframe:(since i'm subclassing uibutton i'm not using buttonwithtype:) button doesn't display. how set button type in case?:

my view controller:

    activityindicatorbutton *button = [[activityindicatorbutton alloc] initwithframe:cgrectmake(10, 10, 300, 44)];     [button addtarget:self action:@selector(buttonpressed) forcontrolevents:uicontroleventtouchupinside];     [button settitle:@"older posts..." forstate: uicontrolstatenormal];     [cell addsubview:button];     [button release]; 

my activityindicatorbutton class:

#import <foundation/foundation.h>   @interface activityindicatorbutton : uibutton {      uiactivityindicatorview *_activityview; }  -(void)startanimating; -(void)stopanimating; @end  @implementation activityindicatorbutton  - (id)initwithframe:(cgrect)frame {     if (self=[super initwithframe:frame]) {         _activityview = [[uiactivityindicatorview alloc] initwithactivityindicatorstyle:uiactivityindicatorviewstylegray];         _activityview.frame = cgrectoffset(_activityview.frame, 60.0f, 10.0f);          [self addsubview: _activityview];     }     return self; }  -(void) dealloc{     [super dealloc];     [_activityview release];     _activityview = nil; }  -(void)startanimating {     [_activityview startanimating]; }  -(void)stopanimating {     [_activityview stopanimating]; } @end 

you don’t want subclass uibutton. it’s class cluster, individual instances uiroundrectbutton or other private apple class. trying requires subclass?


Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -