1.私のmainViewはUIScrollViewです。9枚の画像をタイルとしてロードする必要があります。
2. 9imagesを取得し、それをインターフェイス(メインスレッド)にロードするために、関数を別のスレッドとして呼び出しています。そうすることで、インターフェイスの応答性が維持されます。
3.しかし、画像がロードされている場合でも、スレッド全体が完了するまで、画像がUIScrollViewに表示されないという問題があります。しかし、インターフェイスで何らかのアクションを実行している場合は、それぞれがロードされて表示されているのを確認できます。
- つまり、各画像がロードされた後、バックグラウンドスレッドからインターフェイス(メインスレッド)を更新する必要があります。
どうすればいいですか?別のスレッドを使用して呼び出すUIScrollViewに画像をロードするために使用するコードを指定しました。
- (void)setUpDisplay:(NSArray *)array
{
NSAutoreleasePool *pool=[[NSAutoreleasePool alloc] init];
myScrollView.userInteractionEnabled = YES;
myScrollView.multipleTouchEnabled = YES;
int x=0,y=0;
CGRect frame;
for (i = 0; i < 3; i++)
{
if(j == 3)
{
x=x+256;
y = y-768;
}
for (j = 0; j < 3; j++) {
imageView = [[UIImageView alloc] initWithImage:[self getCachedImage:[NSString stringWithFormat:@"url to fetch images"]]];
frame = [imageView frame];
frame.origin.x = x;
frame.origin.y = y;
[imageView setFrame:frame];
imageView.userInteractionEnabled = YES;
imageView.multipleTouchEnabled = YES;
[myScrollView addSubview:imageView];
y = y+256;
[imageView release];
imageView=nil;
}
}
[pool release];
}