Looking for a quick and easy way to show an activity indicator? I found the easiest way was to subclass UIAlertView to make a reusable solution. Click read more for the code.
// ActivityAlertView.h01 | @interface ActivityAlertView : UIAlertView |
03 | UIActivityIndicatorView *activityView; |
06 | @property (nonatomic, retain) UIActivityIndicatorView *activityView; |
// ActivityAlertView.m01 | #import "ActivityAlertView.h" |
03 | @implementation ActivityAlertView |
05 | @synthesize activityView; |
07 | - (id)initWithFrame:(CGRect)frame |
09 | if ((self = [super initWithFrame:frame])) |
11 | self.activityView = [[UIActivityIndicatorView alloc] initWithFrame:CGRectMake(125, 80, 30, 30)]; |
12 | [self addSubview:activityView]; |
13 | activityView.activityIndicatorViewStyle = UIActivityIndicatorViewStyleWhiteLarge; |
14 | [activityView startAnimating]; |
22 | [self dismissWithClickedButtonIndex:0 animated:YES]; |
27 | [activityView release]; |
// Usage02 | activityAlert = [[[ActivityAlertView alloc] |
03 | initWithTitle:@ "Doing Something" |
04 | message:@ "Please wait..." |
05 | delegate:self cancelButtonTitle:nil |
06 | otherButtonTitles:nil] autorelease]; |
0 Comments