iOS开发常用的第三方类库
1 | [HUD hide:YES]; |
对于同步方法一般都是用showWhileExecuting方法,方法执行完成之后会自动隐藏提示效果:
1 | [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES]; |
SVProgressHUD 提示效果
GitHub:https://github.com/samvermette/SVProgressHUD
SVProgressHUD和MBProgressHUD效果差不多,不过不需要使用协议,同时也不需要声明实例。
直接通过类方法进行调用即可:
1 | [SVProgressHUD method] |
可以使用以下方法来显示状态:
1 2 3 4 | + (void)show; + (void)showWithMaskType:(SVProgressHUDMaskType)maskType; + (void)showWithStatus:(NSString*)string; + (void)showWithStatus:(NSString*)string maskType:(SVProgressHUDMaskType)maskType; |
如果需要明确的进度,则使用以下方法:
1 2 3 | + (void)showProgress:(CGFloat)progress; + (void)showProgress:(CGFloat)progress status:(NSString*)status; + (void)showProgress:(CGFloat)progress status:(NSString*)status maskType:(SVProgressHUDMaskType)maskType; |
通过dismiss方法来隐藏提示:
1 | + (void)dismiss; |
另外提供了以下方法用于显示状态,并在1秒后自动隐藏提示(使用的图标来源于Glyphish:http://www.glyphish.com/):
1 2 3 | + (void)showSuccessWithStatus:(NSString*)string; + (void)showErrorWithStatus:(NSString *)string; + (void)showImage:(UIImage*)image status:(NSString*)string;// use 28x28 white pngs |
ZAActivityBar 提示效果
GitHub:https://github.com/zacaltman/ZAActivityBar
ZAActivityBar和SVProgressHUD非常相似,它提供了更加简洁的API来显示提示效果。
ZAActivityBar使用的动画效果来源于ZKBounceAnimation(https://github.com/khanlou/SKBounceAnimation),成功、失败的状态图标来源于Pictos(http://pictos.cc/)。
显示加载状态:
1 | [ZAActivityBar showWithStatus:@加载中...]; |
显示成功、失败状态:
1 2 | [ZAActivityBar showSuccessWithStatus:@成功!]; [ZAActivityBar showErrorWithStatus:@失败!]; |
隐藏提示:
1 | [ZAActivityBar dismiss]; |
SBJson JSON解析
官方: http://sbjson.org/
GitHub:https://github.com/stig/json-framework
API使用起来稍显繁琐,特别是初始化的时候:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | @interface TestViewController ()SBJsonStreamParserAdapterDelegate> { SBJsonStreamParser *parser; SBJsonStreamParserAdapter *adapter; } // 冗长的初始化方法足以吓到一大片人 - (void)initSBJSON { // We don't want *all* the individual messages from the // SBJsonStreamParser, just the top-level objects. The stream // parser adapter exists for this purpose. adapter = [[SBJsonStreamParserAdapter alloc] init];
// Set ourselves as the delegate, so we receive the messages // from the adapter. adapter.delegate = self;
// Create a new stream parser.. parser = [[SBJsonStreamParser alloc] init];
// .. and set our adapter as its delegate. parser.delegate = adapter;
// Normally it's an error if JSON is followed by anything but // whitespace. Setting this means that the parser will be // expecting the stream to contain multiple whitespace-separated // JSON documents. parser.supportMultipleDocuments = YES; } #pragma mark SBJsonStreamParserAdapterDelegate methods - (void)parser:(SBJsonStreamParser *)parser foundArray:(NSArray *)array { [NSExceptionraise:@unexpected format:@Should not get here]; } - (void)parser:(SBJsonStreamParser *)parser foundObject:(NSDictionary *)dict { NSLog(@SBJson parser foundObject); // 处理返回的数据 } // 使用ASIHTTPRequest请求测试 - (void) loadData { __block ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url]; [request setRequestMethod:@POST]; [request setCompletionBlock:^{
|
- Windows CE 进程、线程和内存管理(11-09)
- RedHatLinux新手入门教程(5)(11-12)
- uClinux介绍(11-09)
- openwebmailV1.60安装教学(11-12)
- Linux嵌入式系统开发平台选型探讨(11-09)
- Windows CE 进程、线程和内存管理(二)(11-09)