試試這個:
#import "ASIHTTPRequest.h"
//In a method
[self performSelectorInBackground:@selector(DownLoadImageInBackground:) withObject:imgUrlArr];
-(void) DownLoadImageInBackground:(NSArray *)imgUrlArr1
{
NSURL * url = [Image URL];
ASIHTTPRequest *request = [ASIHTTPRequest requestWithURL:url];
[request setDelegate:self];
[request startAsynchronous];
}
-(void)requestFailed:(ASIHTTPRequest *)request
{
NSLog(@"URL Fail : %@",request.url);
NSError *error = [request error];
// you can give here alert too..
}
-(void)requestFinished:(ASIHTTPRequest *)request
{
NSData *responseData = [request responseData];
UIImage *imgInBackground = [[UIImage alloc]
initWithData:responseData];
[imageView setImage: imgInBackground];
}
這可以幫助你:我也同時加載了一些圖片,因此,有沒有合適的數據圖像顯示黑屏。爲了避免這種情況,請嘗試調整您的imageview的大小。
你崩潰之前得到控制檯的東西。 – iamsult
請發佈一些崩潰日誌。 – HelmiB