• 等待指示器(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];
    }

  • 相关阅读:
    2015.07.20MapReducer源码解析(笔记)
    Hive(笔记)
    HDFS入门(1)
    Zookepper(2015.08.16笔记)
    USB_ModeSwitch 介绍(转)
    Perl 模块 Getopt::Std 和 Getopt::Long
    在linux下设置开机自动启动程序的方法
    gcc Makefile 入门
    Linuxexec函数族及system函数
    signal(SIGHUP, SIG_IGN)的含义
  • 原文地址:https://www.cnblogs.com/yaoxc/p/3719271.html
Copyright © 2020-2023  润新知