IOS第三方之MBProgressHUD
ios 第三方
2023-09-14 08:57:59 时间
// Created by City--Online on 15/6/15.
// Copyright (c) 2015年 City--Online. All rights reserved.
#import "ViewController.h"
#import "MBProgressHUD.h"
@interface ViewController () MBProgressHUDDelegate,NSURLConnectionDataDelegate
@property(nonatomic,strong) MBProgressHUD *hud;
@property(nonatomic,assign) long long expectedLength;
@property(nonatomic,assign) long long currentLength;
@implementation ViewController
- (void)viewDidLoad {
[super viewDidLoad];
//普通提示框
UIButton *simpleBtn=[UIButton buttonWithType:UIButtonTypeSystem];
[simpleBtn setTitle:@"普通" forState:UIControlStateNormal];
[simpleBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
simpleBtn.frame=CGRectMake(20, 70, 100, 100);
simpleBtn.backgroundColor=[UIColor redColor];
simpleBtn.tag=10001;
[self.view addSubview:simpleBtn];
//显示进度
UIButton *progressBtn=[UIButton buttonWithType:UIButtonTypeSystem];
[progressBtn setTitle:@"进度" forState:UIControlStateNormal];
[progressBtn addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
progressBtn.frame=CGRectMake(130, 70, 100, 100);
progressBtn.backgroundColor=[UIColor redColor];
progressBtn.tag=10002;
[self.view addSubview:progressBtn];
//自定义视图
UIButton *customBtn=[UIButton buttonWithType:UIButtonTypeSystem];
[customBtn setTitle:@"自定义" forState:UIControlStateNormal];
[customBtn addTarget:self action:@selector(customClick:) forControlEvents:UIControlEventTouchUpInside];
customBtn.frame=CGRectMake(20, 180, 100, 100);
customBtn.backgroundColor=[UIColor redColor];
customBtn.tag=10003;
[self.view addSubview:customBtn];
//Window视图
UIButton *windowBtn=[UIButton buttonWithType:UIButtonTypeSystem];
[windowBtn setTitle:@"Window" forState:UIControlStateNormal];
[windowBtn addTarget:self action:@selector(windowClick:) forControlEvents:UIControlEventTouchUpInside];
windowBtn.frame=CGRectMake(130, 180, 100, 100);
windowBtn.backgroundColor=[UIColor redColor];
windowBtn.tag=10004;
[self.view addSubview:windowBtn];
//多提示框
UIButton *mixBtn=[UIButton buttonWithType:UIButtonTypeSystem];
[mixBtn setTitle:@"多提示框" forState:UIControlStateNormal];
[mixBtn addTarget:self action:@selector(mixClick:) forControlEvents:UIControlEventTouchUpInside];
mixBtn.frame=CGRectMake(20, 290, 100, 100);
mixBtn.backgroundColor=[UIColor redColor];
mixBtn.tag=10004;
[self.view addSubview:mixBtn];
//多提示框
UIButton *connectionBtn=[UIButton buttonWithType:UIButtonTypeSystem];
[connectionBtn setTitle:@"Connection" forState:UIControlStateNormal];
[connectionBtn addTarget:self action:@selector(connectionClick:) forControlEvents:UIControlEventTouchUpInside];
connectionBtn.frame=CGRectMake(130, 290, 100, 100);
connectionBtn.backgroundColor=[UIColor redColor];
connectionBtn.tag=10004;
[self.view addSubview:connectionBtn];
[self.view addSubview:_hud]; // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) _hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]]; // Set custom view mode _hud.mode = MBProgressHUDModeCustomView; _hud.delegate = self; _hud.labelText=@"Loading"; _hud.detailsLabelText=@"updating data"; _hud.square=YES; [_hud show:YES]; [_hud hide:YES afterDelay:3];
_hud=[[MBProgressHUD alloc]initWithWindow:self.view.window]; [self.view.window addSubview:_hud]; _hud.delegate=self; _hud.labelText=@"Loading"; [_hud showWhileExecuting:@selector(task) onTarget:self withObject:nil animated:YES]; //多提示框 -(void)mixClick:(id)sender _hud = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:_hud]; _hud.delegate = self; _hud.labelText = @"Connecting"; // _hud.minSize = CGSizeMake(135.f, 135.f); [_hud showWhileExecuting:@selector(mixedTask) onTarget:self withObject:nil animated:YES]; -(void)connectionClick:(id)sender NSURL *url=[NSURL URLWithString:@"http://a1408.g.akamai.net/5/1408/1388/2005110403/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_iPod.m4v.zip"]; NSURLRequest *request=[NSURLRequest requestWithURL:url]; NSURLConnection *connection=[[NSURLConnection alloc]initWithRequest:request delegate:self]; [connection start]; _hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES]; _hud.delegate=self; _hud.mode=MBProgressHUDModeDeterminate; -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response _expectedLength=MAX(response.expectedContentLength, 1); _currentLength=0;
_hud.customView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]]; _hud.mode=MBProgressHUDModeCustomView; [_hud hide:YES afterDelay:2]; -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error [_hud hide:YES]; //显示进度 - (void)myProgressTask { // This just increases the progress indicator in a loop float progress = 0.0f; while (progress 1.0f) { progress += 0.01f; _hud.progress = progress; usleep(50000);
sleep(2); // UIImageView is a UIKit class, we have to initialize it on the main thread __block UIImageView *imageView; dispatch_sync(dispatch_get_main_queue(), ^{ UIImage *image = [UIImage imageNamed:@"37x-Checkmark.png"]; imageView = [[UIImageView alloc] initWithImage:image]; _hud.customView =imageView; _hud.mode = MBProgressHUDModeCustomView; _hud.labelText = @"Completed"; sleep(2); - (void)hudWasHidden:(MBProgressHUD *)hud { // Remove HUD from screen when the HUD was hidded [_hud removeFromSuperview]; _hud=nil; - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. @end
官网里已经提供了足够多的例子供我们使用,但在实现开发中,我们用到的只是其中的一小部分而已。
IOS开发---菜鸟学习之路--(十三)-利用MBProgressHUD进行异步获取数据 本章将介绍如何利用MBProgressHUD实现异步处理数据。 其实我本来只是像实现一个加载数据时提示框的效果,然后问了学长知道了这个类,然后就使用了 接着就发现了一个“BUG” 再然后就发现原来MBProgressHUD处理数据的时候是异步处理的 而所谓的“BUG”其实是在我实现了ASIFormDataRequest 异步处理数据后 又利用MBProgressHUD来显示加载数据框所导致的。
iOS网络编程-MBProgressHUD等待指示器 p 第三方的等待指示器,MBProgressHUD就是第三方提供的等待指示器框架。下面是MBProgressHUD提供的等待指示器样式,它们基本可以分为:未知结束时间和已知结束时间两大类等待指示器,在MBProgressHUD中可以为等待指示器添加标签和详细标签 /p p align= center /p p align= center a href= http://www.
[ios开发]-APP-上架流程 由于苹果的机制,在非越狱机器上安装必须通过官方的Appstore, 开发者开发好应用后上传Appstore,也需要通过审核等环节。 AppCan作为一个跨主流平台的一个开发平台,也对ipa包上传Appstore作了支持。 本文从三个流程来介绍如何实现AppCan在 线编译出ipa包,以及上传到苹果Appstore。
社会主义 从.Net到iOS,在撸的道路上越走越远,工作之余经营着博客园http://www.cnblogs.com/5ishare,欢迎小伙伴(妹子更好)一起交流,谈谈人生理想。作为经常从网上索取免费资料的一员,要有回报回报的思想,也让更多的人少走弯路.
[self.view addSubview:_hud]; // Make the customViews 37 by 37 pixels for best results (those are the bounds of the build-in progress indicators) _hud.customView = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]]; // Set custom view mode _hud.mode = MBProgressHUDModeCustomView; _hud.delegate = self; _hud.labelText=@"Loading"; _hud.detailsLabelText=@"updating data"; _hud.square=YES; [_hud show:YES]; [_hud hide:YES afterDelay:3];
_hud=[[MBProgressHUD alloc]initWithWindow:self.view.window]; [self.view.window addSubview:_hud]; _hud.delegate=self; _hud.labelText=@"Loading"; [_hud showWhileExecuting:@selector(task) onTarget:self withObject:nil animated:YES]; //多提示框 -(void)mixClick:(id)sender _hud = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:_hud]; _hud.delegate = self; _hud.labelText = @"Connecting"; // _hud.minSize = CGSizeMake(135.f, 135.f); [_hud showWhileExecuting:@selector(mixedTask) onTarget:self withObject:nil animated:YES]; -(void)connectionClick:(id)sender NSURL *url=[NSURL URLWithString:@"http://a1408.g.akamai.net/5/1408/1388/2005110403/1a1a1ad948be278cff2d96046ad90768d848b41947aa1986/sample_iPod.m4v.zip"]; NSURLRequest *request=[NSURLRequest requestWithURL:url]; NSURLConnection *connection=[[NSURLConnection alloc]initWithRequest:request delegate:self]; [connection start]; _hud=[MBProgressHUD showHUDAddedTo:self.view animated:YES]; _hud.delegate=self; _hud.mode=MBProgressHUDModeDeterminate; -(void)connection:(NSURLConnection *)connection didReceiveResponse:(NSURLResponse *)response _expectedLength=MAX(response.expectedContentLength, 1); _currentLength=0;
_hud.customView=[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"37x-Checkmark.png"]]; _hud.mode=MBProgressHUDModeCustomView; [_hud hide:YES afterDelay:2]; -(void)connection:(NSURLConnection *)connection didFailWithError:(NSError *)error [_hud hide:YES]; //显示进度 - (void)myProgressTask { // This just increases the progress indicator in a loop float progress = 0.0f; while (progress 1.0f) { progress += 0.01f; _hud.progress = progress; usleep(50000);
sleep(2); // UIImageView is a UIKit class, we have to initialize it on the main thread __block UIImageView *imageView; dispatch_sync(dispatch_get_main_queue(), ^{ UIImage *image = [UIImage imageNamed:@"37x-Checkmark.png"]; imageView = [[UIImageView alloc] initWithImage:image]; _hud.customView =imageView; _hud.mode = MBProgressHUDModeCustomView; _hud.labelText = @"Completed"; sleep(2); - (void)hudWasHidden:(MBProgressHUD *)hud { // Remove HUD from screen when the HUD was hidded [_hud removeFromSuperview]; _hud=nil; - (void)didReceiveMemoryWarning { [super didReceiveMemoryWarning]; // Dispose of any resources that can be recreated. @end
官网里已经提供了足够多的例子供我们使用,但在实现开发中,我们用到的只是其中的一小部分而已。
IOS开发---菜鸟学习之路--(十三)-利用MBProgressHUD进行异步获取数据 本章将介绍如何利用MBProgressHUD实现异步处理数据。 其实我本来只是像实现一个加载数据时提示框的效果,然后问了学长知道了这个类,然后就使用了 接着就发现了一个“BUG” 再然后就发现原来MBProgressHUD处理数据的时候是异步处理的 而所谓的“BUG”其实是在我实现了ASIFormDataRequest 异步处理数据后 又利用MBProgressHUD来显示加载数据框所导致的。
iOS网络编程-MBProgressHUD等待指示器 p 第三方的等待指示器,MBProgressHUD就是第三方提供的等待指示器框架。下面是MBProgressHUD提供的等待指示器样式,它们基本可以分为:未知结束时间和已知结束时间两大类等待指示器,在MBProgressHUD中可以为等待指示器添加标签和详细标签 /p p align= center /p p align= center a href= http://www.
[ios开发]-APP-上架流程 由于苹果的机制,在非越狱机器上安装必须通过官方的Appstore, 开发者开发好应用后上传Appstore,也需要通过审核等环节。 AppCan作为一个跨主流平台的一个开发平台,也对ipa包上传Appstore作了支持。 本文从三个流程来介绍如何实现AppCan在 线编译出ipa包,以及上传到苹果Appstore。
社会主义 从.Net到iOS,在撸的道路上越走越远,工作之余经营着博客园http://www.cnblogs.com/5ishare,欢迎小伙伴(妹子更好)一起交流,谈谈人生理想。作为经常从网上索取免费资料的一员,要有回报回报的思想,也让更多的人少走弯路.
相关文章
- (NO.00003)iOS游戏简单的机器人投射游戏成形记(十四)
- (NO.00002)iOS游戏精灵战争雏形(六)
- (NO.00002)iOS游戏精灵战争雏形(一)
- Ios 调用Appstore 下载界面 [[UIApplication sharedApplication] openURL
- unity 引入 ios 第三方sdk
- IOS设备信息与机型对照表
- 整理常用的iOS第三方资源
- iOS开发之使用CocoaPods更新第三方出现“target overrides the `OTHER_LDFLAGS`……”问题解决方案
- iOS开发之网络编程--使用NSURLConnection实现大文件断点续传下载
- Ios开发之 -- js和ios的交互
- 关于第三方IOS的checkBox框架的使用
- iOS开发UI篇—iOS开发中三种简单的动画设置
- IOS第三方之SDWebImage
- iOS学习之应用偏好设置
- IOS中 浅谈iOS中MVVM的架构设计与团队协作
- iOS开发那些事--性能优化–内存泄露问题的解决
- iOS UIButton Highlighted是指点击还没有松开的状态
- iOS面试 第三方库
- iOS RunLoop面试总结
- iOS:runtime 消息转发 Method_Swizzling 动态添加方法 动态方法解析
- iOS面试专题一
- iOS 百度地图 要在iOS 11及以上版本使用定位服务
- iOS运行时文档解析(Runtime oc消息转发 objc_msgSend 动态加载方法)
- IOS常用的第三方库(框架)
- 第三方库ios
- iOS开发 - 应用内打开第三方应用并传值