私のアプリケーションはデータベースを 50 回クエリし、適切な UIImageView を別の UIImageView に追加することでそれに応じて反応します。これにより、ループごとにアプリケーションがすぐに表示されるようになります。
残念ながら、何晩も経った後、私はそれを機能させることができませんでした。アプリケーションはすぐには UIImageView を表示しません。そうは言っても、ミッドループ中にズームインまたはズームアウトすると、UIImageViewsが表示されます! 私は何かが欠けているに違いない...
これまでのところ、最後の部分 [UIScrollView performSelector.... を除くすべてのコードが機能します。
どうぞよろしくお願いいたします。
UIScrollView *firstView;
UIImageView *secondView;
UIImageView *thirdView;
NSOperationQueue *queue;
NSInvocationOperation *operation;
- (void)viewDidAppear:(BOOL)animated
{
queue = [NSOperationQueue new];
operation = [[NSInvocationOperation alloc] initWithTarget:self selector:@selector(getData) object:nil];
[queue addOperation:operation];
}
- (void) getData
{
for (i=0 ; i < 50 ; i++)
{
//All the codes to facilitate XML parsing here
[nsXMLParser setDelegate:parser];
[BOOL success = [nsXMLParser parse];
if (success)
{
if ([parser.currentValue isEqualToString:@"G"])
thirdView.image = greenTick.jpg;
[secondView addSubview:thirdView];
}
else
{
NSLog(@"Error parsing document!");
}
}
[thirdView performSelectorOnMainThread:@selector(setNeedsDisplay) withObject:nil waitUntilDone: YES];
}