zoukankan      html  css  js  c++  java
  • MBProgressHUDDemo

    //

    //  ZBMainViewController.m

    //  MBProgressHUDDemo

    //

    //  Created by 张先森 on 14/11/27.

    //  Copyright (c) 2014年 zhibin. All rights reserved.

    //

    #import "ZBMainViewController.h"

    #import "MBProgressHUD+MJ.h"

    @interface ZBMainViewController ()

    {

        MBProgressHUD *HUD;

    }

    - (IBAction)showTextDialog:(id)sender;

    - (IBAction)showProgressOne:(id)sender;

    - (IBAction)showProgressTwo:(id)sender;

    - (IBAction)showProgressThree:(id)sender;

    - (IBAction)showCustomDialog:(id)sender;

    - (IBAction)showAllTextDialog:(id)sender;

    @end

    @implementation ZBMainViewController

    - (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil

    {

        self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];

        if (self) {

            // Custom initialization

        }

        return self;

    }

    - (void)viewDidLoad

    {

        [super viewDidLoad];

        // Do any additional setup after loading the view from its nib.

    }

    - (void)didReceiveMemoryWarning

    {

        [super didReceiveMemoryWarning];

        // Dispose of any resources that can be recreated.

    }

    - (IBAction)showTextDialog:(id)sender {

        HUD=[[MBProgressHUD alloc] initWithView:self.view];

        

        [self.view addSubview:HUD];

        HUD.dimBackground=YES;

        HUD.labelText=@"请稍后";

        

        [HUD showAnimated:YES whileExecutingBlock:^{

            sleep(10);

        } completionBlock:^{

                 [HUD removeFromSuperview];

        }];

        

    }

    - (IBAction)showProgressOne:(id)sender {

        HUD =[[MBProgressHUD alloc] initWithView:self.view];

        [self.view addSubview:HUD];

        HUD.mode=MBProgressHUDModeDeterminate;

          HUD.labelText=@"请稍后";

        [HUD showAnimated:YES whileExecutingBlock:^{

            

            float progress = 0.0f;

            while (progress < 1.0f) {

                progress += 0.01f;

                HUD.progress = progress;

                usleep(10000);

            }

        } completionBlock:^{

            [HUD removeFromSuperview];

       

            HUD = nil;

        }];

        

        

    }

    - (IBAction)showProgressTwo:(id)sender {

        

        HUD=[[MBProgressHUD alloc] initWithView:self.view];

        [self.view addSubview:HUD];

           HUD.labelText=@"请稍后";

        

            HUD.mode=MBProgressHUDModeAnnularDeterminate;

        [HUD showAnimated:YES whileExecutingBlock:^{

            

            float progress = 0.0f;

            while (progress < 1.0f) {

                progress += 0.01f;

                HUD.progress = progress;

                usleep(10000);

            }

        } completionBlock:^{

            [HUD removeFromSuperview];

            

            HUD = nil;

        }];

    }

    - (IBAction)showProgressThree:(id)sender {

        

        HUD=[[MBProgressHUD alloc] initWithView:self.view];

        [self.view addSubview:HUD];

        HUD.labelText=@"请稍后";

        

        HUD.mode=MBProgressHUDModeDeterminateHorizontalBar;

        [HUD showAnimated:YES whileExecutingBlock:^{

            

            float progress = 0.0f;

            while (progress < 1.0f) {

                progress += 0.01f;

                HUD.progress = progress;

                usleep(10000);

            }

        } completionBlock:^{

            [HUD removeFromSuperview];

            

            HUD = nil;

        }];

    }

    - (IBAction)showCustomDialog:(id)sender {

        HUD=[[MBProgressHUD alloc] initWithView:self.view];

        HUD.mode=MBProgressHUDModeCustomView;

         HUD.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"tabbar_profile_selected_os7"]];

        

        [self.view addSubview:HUD];

        HUD.labelText=@"请稍后再试试";

        [HUD showAnimated:YES whileExecutingBlock:^{

            

                sleep(2);

            

        } completionBlock:^{

            

            

            [HUD removeFromSuperview];

          

            HUD = nil;

        }];

        

        

    }

    - (IBAction)showAllTextDialog:(id)sender {

        

        HUD = [[MBProgressHUD alloc] initWithView:self.view];

        [self.view addSubview:HUD];

        

        HUD.labelText = @"操作成功";

        HUD.mode = MBProgressHUDModeText;

      //  HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Checkmark"]] ];

        [HUD showAnimated:YES whileExecutingBlock:^{

            sleep(2);

        } completionBlock:^{

            [HUD removeFromSuperview];

        

            HUD = nil;

        }];

        

        

    }

    @end

  • 相关阅读:
    Java 基础 ------- 面向对象(三) 继承
    虚拟机安装系统--- 安装VMware Tools(五)
    'sqlplus'不是内部或外部命令,也不是可运行的程序
    点餐系统(java基础、数据库、jsp、servlet)
    jsp页面pageContext.setAttribute报错
    Spring事务管理(编码式、配置文件方式、注解方式)
    并发控制
    Spring整合JDBC(连接池、JDBC模板、Dao配置到Spring容器、配置文件的优化)
    Spring的aop思想(名词、aop的配置)
    spring:spring的核心API
  • 原文地址:https://www.cnblogs.com/zhibin/p/4127345.html
Copyright © 2011-2022 走看看