2013年2月7日 星期四

test APIs on CocoaPods as well, first one is SVProgressHUD

//https://github.com/samvermette/SVProgressHUD // Podfile platform :ios pod 'JSONKit', '~> 1.4' pod 'Reachability', '~> 3.1.0' pod 'InAppSettingsKit', '~> 1.0' pod 'AFNetworking', '~> 0.10.1' pod 'GDataXML-HTML', '~> 1.0.0' pod 'SVProgressHUD', '~> 0.9' // it can show image as well. //+ (void)showImage:(UIImage*)image status:(NSString*)string; // use 28x28 white pngs //SVProgressHUD in .h - (IBAction)show; - (IBAction)showWithStatus; - (IBAction)dismiss; - (IBAction)dismissSuccess; - (IBAction)dismissError; //SVProgressHUD in .m #import "SVProgressHUD.h" //@implementation KATDetailViewController //{ NSTimer *timer; //} #pragma mark - Show Methods Sample - (void)show { [SVProgressHUD show]; } - (void)showWithStatus { [SVProgressHUD showWithStatus:@"Doing Stuff"]; } static float progress = 0.0f; - (void)showWithProgress:(id)sender { progress = 0.0f; [SVProgressHUD showProgress:0 status:@"Loading"]; if (timer) { [timer invalidate]; } timer = [NSTimer scheduledTimerWithTimeInterval:0.3f target:self selector:@selector(setProgress) userInfo:nil repeats:YES]; } - (void)setProgress { progress+=0.1f; [SVProgressHUD showProgress:progress status:@"Loading"]; if(progress >= 1.0f) { [timer invalidate]; timer = nil; [self performSelector:@selector(dismiss) withObject:nil afterDelay:0.4f]; } } #pragma mark - Dismiss Methods Sample - (void)dismiss { [SVProgressHUD dismiss]; [timer invalidate]; } - (void)dismissSuccess { [SVProgressHUD showSuccessWithStatus:@"Great Success!"]; [timer invalidate]; } - (void)dismissError { [SVProgressHUD showErrorWithStatus:@"Failed with Error"]; [timer invalidate]; }

沒有留言:

張貼留言