首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 移动开发 > 移动开发 >

MBProgressHUD应用备忘录

2012-09-25 
MBProgressHUD使用备忘录MBProgressHUD是替代UIProgressHUD的一个小工具,使用方法也非常简单。下载地址是:

MBProgressHUD使用备忘录
MBProgressHUD是替代UIProgressHUD的一个小工具,使用方法也非常简单。
下载地址是: http://github.com/matej/MBProgressHUD

#import <UIKit/UIKit.h>#import "MBProgressHUD.h"@interface HudDemoViewController : UIViewController <MBProgressHUDDelegate> {MBProgressHUD *HUD;}- (IBAction) showWithLabel:(id)sender;- (void) myTask;@end


@implementation HudDemoViewController- (IBAction) showWithLabel:(id)sender {// Should be initialized with the windows frame so the HUD disables all user input by covering the entire screenHUD = [[MBProgressHUD alloc] initWithWindow:[UIApplication sharedApplication].keyWindow];// Add HUD to screen[self.view.window addSubview:HUD];// Regisete for HUD callbacks so we can remove it from the window at the right timeHUD.delegate = self;HUD.labelText = @"Loading";// Show the HUD while the provided method executes in a new thread[HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];}- (void) myTask {// Do something usefull in here instead of sleeping ...sleep(3);}- (void)hudWasHidden {// Remove HUD from screen when the HUD was hidded[HUD removeFromSuperview];[HUD release];}@end

热点排行