在我的iPhone應用程序中,我必須顯示縮略圖圖像的預覽。實際上,我們將從遠程服務器獲取該預覽圖像。在屏幕上加載大圖像之前,我必須顯示預加載視圖,但實際上這個預加載視圖並未出現在屏幕上。從遠程服務器獲取圖像
我使用的代碼是:
zoomview=[[UIView alloc]initWithFrame:CGRectMake(0,0,320,460)];
imageloadview.backgroundColor=[UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.5];
[self.view addSubview:imageloadview];
[activity startAnimating];
[self loadimageview];
這裏,而不是裝在這個加載視圖方法執行畫面放大觀看,但我想顯示從服務器獲取大圖像之前預加載視圖。
-(void)loadimageview
{
imageloader.image=[UIImage imageNamed:@""];
[self loadimage];
}
-(void)loadimage
{
NSData *data=[NSData dataWithContentsOfURL:[NSURL URLWithString:[picfullarray objectAtIndex:0]]];
if([data length]==0)
{
NSLog(@"data");
}
else
{
UIImage *image1=[UIImage imageWithData:data];
imageloader.image=image1;
[activity stopAnimating];
[loadlabel1 setText:@""];
}
}
如何在從服務器獲取大圖像之前在iPhone屏幕上顯示預裝視圖?
http://stackoverflow.com/questions/9763979/download-image-asynchronously/9766123#9766123也許異步圖像下載可能會幫助你.. –