zoukankan      html  css  js  c++  java
  • 等待指示器(3) -- 第三方MBProgressHUD

    MBProgressHUD依赖的框架:Foundation.framework、UIKit.framework、CoreGraphics.framework。

    1>MBProgressHUD类中获取MBProgressHUD对象方法:

    // 创建MBProgressHUD对象添加到View视图中,并显示等待指示器

     + (MBProgressHUD *)showHUDAddedTo:(UIView *)view  animated:(BOOL )animated ;

    // 从顶级视图的子视图中查找MBProgressHUD对象

    + (MBProgressHUD *)HUDForView:(UIView *)view;

    2>MBProgressHUD中常用属性

    mode:设定指示器显示的样式

    labelText:设置等待指示器标签的内容

    detailsLabelText:设置等待指示器详细标签内容

    customView:设置自定义视图

    - (void)startRequest

    {

        // 初始化MBProgressHUD

        MBProgressHUD *hud = [MBProgressHUD showHUDAddedTo: self.view animated :YES];

        hud.mode = MBProgressHUDModeCustomView;

        hud.labelText = @"Loading...";

        NSString *strUrl = [[NSString alloc] initWithFormat:@"http://iosbook3.com/service/mynotes/webservice.php?                      email=%@&type=%@&action=%@",@"ios_yaoxinchao@163.com",@"JSON",@"query"];   

        NSURL *url = [NSURL URLWithString:[strUrl URLEncodedString]];  

        __weak  ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];     

        [request setCompletionBlock:^{  // 设置成功完成时回调的Block

          NSData *data = [request responseData];  

          NSDictionary *resDict = [NSJSONSerialization JSONObjectWithData:data options:NSJSONReadingAllowFragments error:nil];

          。。。。

          [MBProgressHUD hideHUDForView:self.view  animated:YES];

        }];

        [request setFailedBlock:^{  // 设置失败时回调的Block

          NSError *error = [request error];

          NSLog(@"%@",[error localizedDescription]);

          [MBProgressHUD hideHUDForView:self.view  animated:YES];

        }];

        [request startAsynchronous];
    }

  • 相关阅读:
    MFC通过Http Post数据到Web端
    C++解析JSON格式数据
    APScheduler最基本的用法
    error connection reset by peer 104
    navicat远程连接mysql错误
    ubuntu18.04 校准时间
    ubuntu下python在pycharm环境下安装setuptools和pip,和distutils.core
    ubuntu下pycharm快捷方式创建
    django无法加载样式
    YAML快速入门
  • 原文地址:https://www.cnblogs.com/yaoxc/p/3719271.html
Copyright © 2011-2022 走看看