视图显示延迟 [英] View showed delay

查看:77
本文介绍了视图显示延迟的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的viewDidAppear方法在下面. 我的视图有一个正在制作动画的activieIndicator和一个imageView. 在viewDidAppear中,我从服务器加载图像,该图像将用作上述imageView的图像. 我要等到图像完全加载后,视图才会显示动画指示符. 但是我做不到. 直到完整的图像加载,我看不到我的看法. 在图像加载过程中,我看到一个黑色的视图.

-(void)viewDidAppear
{
     NSLog(@"view did appear");
     [super viewDidAppear:animated];
     NSData *data=[NSData dataWithContentsOfURL:[NSURL          
     URLWithString:@"http://riseuplabs.com/applications/christmaswallpaper/images/1.jpg"]];
}

有什么解决办法吗?

解决方案

查看如何异步下载数据.请参见此处.

>

@nduplessis的答案是一个很好的答案,并且比较容易,尽管使用NSURLConnection异步有很多好处.如果您急于不想执行新技术,那么他的答案就是该走的路.

请考虑将其作为一种做法,从所有对您问题的回答中选择一个答案.它有助于在这里建立我们的社区.

My viewDidAppear methods is in below. My view has a activieIndicator that is animating and a imageView. In viewDidAppear I load an image from my server which will be used as an image of the above imageView. I want until my image is fully loaded, my view will show the animating indicator. But I can not do it. Until full image load, i can not see my view. during image loading i see a black view.

-(void)viewDidAppear
{
     NSLog(@"view did appear");
     [super viewDidAppear:animated];
     NSData *data=[NSData dataWithContentsOfURL:[NSURL          
     URLWithString:@"http://riseuplabs.com/applications/christmaswallpaper/images/1.jpg"]];
}

is there any solution???

解决方案

Look at how to download data asynchronously. See here.

@nduplessis's answer is a good one, and is easier, although there are benefits to using NSURLConnection asynch. His answer would be the way to go if you are in a hurry and don't want to implement a new technique.

And please consider making it a practice to select an answer from all the responses to your questions. It helps build our community here.

这篇关于视图显示延迟的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆