IOS常用第三方框架 --- ZAActivityBar 提示效果

本文介绍了GitHub上的ZAActivityBar,它提供了一个简洁的API来显示加载、成功和失败状态的提示效果。同时,文章对比了其与SVProgressHUD的相似之处,并介绍了如何使用它进行加载状态的显示、成功与失败状态的提示以及如何隐藏提示。此外,还提到了用于处理JSON数据的多个库,包括SBJson、JSONKit等,详细解释了它们的使用方法,并强调了JSONKit在处理中文字符时的优越性。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

GitHub:https://github.com/zacaltman/ZAActivityBar

ZAActivityBar和SVProgressHUD非常相似,它提供了更加简洁的API来显示提示效果。


ZAActivityBar使用的动画效果来源于ZKBounceAnimation(https://github.com/khanlou/SKBounceAnimation),成功、失败的状态图标来源于Pictos(http://pictos.cc/)。


显示加载状态:

[ZAActivityBar showWithStatus:@"加载中..."];


显示成功、失败状态:

[ZAActivityBar showSuccessWithStatus:@"成功!"];[ZAActivityBar showErrorWithStatus:@"失败!"];


隐藏提示:

[ZAActivityBar dismiss];


官方: http://sbjson.org/

GitHub:https://github.com/stig/json-framework


API使用起来稍显繁琐,特别是初始化的时候:

@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 
{
    [NSException raise:@"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:^{        
          // Use when fetching text data        
          //NSString *responseString = [request responseString];        
          // Use when fetching binary data        
          NSData *responseData = [request responseData];        
          NSLog(@"Connection didReceiveData of length: %u", responseData.length);               
      
          // Parse the new chunk of data. The parser will append it to        
          // its internal buffer, then parse from where it left off in        
          // the last chunk.        
          SBJsonStreamParserStatus status = [parser parse:responseData];               

          if (status == SBJsonStreamParserError) 
          {            
             NSLog(@"Parser error: %@", parser.error);       
          } 
          else if (status == SBJsonStreamParserWaitingForData) 
          {
             NSLog(@"Parser waiting for more data");        
          }
     }]; 

    [request setFailedBlock:^{        
                NSError *error = [request error];        
                NSLog(@"failed - %@ %@", [error localizedDescription], error);    
        }];   
  
    [request startAsynchronous];

}



GitHub:https://github.com/johnezang/JSONKit

提供比SBJson更优异的性能以及更加简便的使用方法,但是中文最好使用utf-8格式(/uXXXX),否则容易造成乱码。


API调用起来非常简单,省去了SBJson那么一大堆的方法:

JSONDecoder* decoder = [[JSONDecoder alloc] initWithParseOptions:JKParseOptionNone];

id result = [decoder objectWithData:jsonData];


详细的使用方法请看它的GitHub主页。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值