重庆分公司,新征程启航

为企业提供网站建设、域名注册、服务器等服务

ios开发usleep,IOS开发者模式

如何解决iOS瀑布流运行不流畅

甚至为了performance,所有的加载操作都在后台完成,一定要重用:

网站建设哪家好,找创新互联公司!专注于网页设计、网站建设、微信开发、小程序定制开发、集团企业网站建设等服务项目。为回馈新老客户创新互联还提供了淮阴免费建站欢迎大家使用!

在iOS开发中利用GCD进行多线程编程

iOS开发中使用NSOperationQueue进行多线程操作

避免后台加载完成多个资源之后集中到达占用UI线程的处理时间太长。

这一点可以通过dispatch或者performSelectorInBackground或者NSOperationQueue来实现。

创建cell一般是很慢的。

重用cell解决办法

主要要做到一下几个方面,且在每个操作完成之后进行强制等待。

这一点可以通过NSOperationQueue来实现。见:

除了UI部分,可以用usleep(int microSeconds)来解决,将资源到UI的展现过程放在队列中逐个执行,可以在view创建之初就创建足够多的cell在重用队列中

ios mbprogresshudmodedeterminate 怎么动画

,然后把两个MBProgressHUD.h和MBProgressHUD.m放到自己的项目就可以了。这里有一个小Demo可以参考一下。

头文件部分:

#import UIKit/UIKit.h#import "MBProgressHUD.h"@interface ViewController : UIViewController{ 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

实现文件部分

#import "ViewController.h"@interface ViewController ()@end@implementation ViewController- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view, typically from a 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; //把当前的view置于后台 HUD.labelText = @"请稍等"; //显示对话框 [HUD showAnimated:YES whileExecutingBlock:^{ sleep(3); } completionBlock:^{ }];}- (IBAction)showProgressOne:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:HUD]; HUD.labelText = @"正在加载"; HUD.mode = MBProgressHUDModeDeterminate; //HUD.mode = MBProgressHUDModeAnnularDeterminate; [HUD showAnimated:YES whileExecutingBlock:^{ float progress = 0.0f; while (progress 1.0f) { progress += 0.01f; HUD.progress = progress; usleep(5000); } } completionBlock:^{ [HUD removeFromSuperview]; [HUD release]; HUD = nil; }];}- (IBAction)showProgressTwo:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:HUD]; HUD.labelText = @"正在加载"; HUD.mode = HUD.mode = MBProgressHUDModeAnnularDeterminate; [HUD showAnimated:YES whileExecutingBlock:^{ float progress = 0.0f; while (progress 1.0f) { progress += 0.01f; HUD.progress = progress; usleep(5000); } } completionBlock:^{ [HUD removeFromSuperview]; [HUD release]; 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(5000); } } completionBlock:^{ [HUD removeFromSuperview]; [HUD release]; HUD = nil; }];}- (IBAction)showCustomDialog:(id)sender { HUD = [[MBProgressHUD alloc] initWithView:self.view]; [self.view addSubview:HUD]; HUD.labelText = @"操作成功"; HUD.mode = MBProgressHUDModeCustomView; HUD.customView = [[[UIImageView alloc] initWithImage:[UIImage imageNamed:@"Checkmark"]] autorelease]; [HUD showAnimated:YES whileExecutingBlock:^{ sleep(2); } completionBlock:^{ [HUD removeFromSuperview]; [HUD release]; 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"]] autorelease]; [HUD showAnimated:YES whileExecutingBlock:^{ sleep(2); } completionBlock:^{ [HUD removeFromSuperview]; [HUD release]; HUD = nil; }]; }- (void)dealloc { [super dealloc];}@end


文章名称:ios开发usleep,IOS开发者模式
转载来源:http://cqcxhl.com/article/dsehpij.html

其他资讯

在线咨询
服务热线
服务热线:028-86922220
TOP