码迷,mamicode.com
首页 > 其他好文 > 详细

MBProgress的使用方法

时间:2015-07-11 14:48:11      阅读:119      评论:0      收藏:0      [点我收藏+]

标签:

1.MBProgressHUD 的弹窗的消息的界面,三种的方式:

第一种的方式: 

-(void)myTask{

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

    [self.view addSubview:HUD];

     HUD.labelText = @"自动扫描中";

     [HUD showWhileExecuting:@selector(myTask) onTarget:self withObject:nil animated:YES];

    sleep(10);

    [self show]; 

}

-(void)show {

    [self.HUD removeFromSuperview];

    TestViewController *test = [[TestViewController alloc]init];

    [self presentViewController:test animated:YES completion:nil];

}

 

第二种的方式:(使用了mb里面的回调的函数)

//使用了回调的方法

-(void)myTask1{

    int duration = 5;

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

    [self.view addSubview: HUD];

    HUD.labelText = @"正在登录,请稍等....";

    [HUD showAnimated:YES whileExecutingBlock:^{

        sleep(duration);

    } completionBlock:^{

        [HUD removeFromSuperview];

        [self show];

    }]; 

}

-(void)show {

    [self.HUD removeFromSuperview];

    TestViewController *test = [[TestViewController alloc]init];

    [self presentViewController:test animated:YES completion:nil];

}

第三种方式:(整个屏幕都充满)

-(void)myTask2{

     self.HUD = [[MBProgressHUD alloc]init];

    self.HUD = [MBProgressHUD showMessage:@"正在查询,请稍等片刻"];

    self.HUD.delegate = self;

    self.timer =   [NSTimer scheduledTimerWithTimeInterval:10 target:self selector:@selector(show) userInfo:nil repeats:NO];   

}

-(void)show {

    [self.HUD removeFromSuperview];

    TestViewController *test = [[TestViewController alloc]init];

    [self presentViewController:test animated:YES completion:nil];

    }

#pragma  mark - MBProgressHUD (MB里面没有这个代理方法,新加了一个方法)

- (void)hudViewWasTapped{

     NSLog(@"调用hud的代理方法");

    [self.HUD removeFromSuperview];

    self.timer = nil;

    self.HUD = nil;

}

 

MBProgress的使用方法

标签:

原文地址:http://www.cnblogs.com/zhufeng1994/p/4638493.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!