title: create uibutton subclass
body: <p>I tried to subclass UIButton to include an activity indicator, but when i use initWithFrame:(since i'm subclassing uibutton i'm not using buttonWithType:) the button doesn't display.  Also how would i set the button type in this case?:</p>
  
  <p>my view controller:</p>
  
  <pre><code>    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];
  </code></pre>
  
  <p>my activityindicatorbutton class:</p>
  
  <pre><code>#import &lt;Foundation/Foundation.h&gt;
  
  
  @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
  </code></pre>