ボタンを押すとアラートビューを表示したい。表示されますが、画面に表示されるまでに時間がかかりすぎます。ボタンを押したときに呼び出す関数は次のとおりです。
-(void)saveAndClose:(id)sender
{
waitForOCR=[[UIAlertView alloc] initWithTitle:@"Processing..." message:@"Please wait." delegate:self cancelButtonTitle:@"Cancel" otherButtonTitles:nil, nil];
waitForOCR.delegate=self;
[waitForOCR show];
if(!isCancelled){
NSMutableArray *dateSaved=[[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:@"dateCaptured"]];
NSDateFormatter *dateText=[[NSDateFormatter alloc] init];
[dateText setDateFormat:@"yyyy-MM-dd"];
NSDate *now=[NSDate date];
NSString *dateValue=[dateText stringFromDate:now];
[dateSaved addObject:dateValue];
NSMutableArray *timeSaved=[[NSMutableArray alloc] initWithArray:[[NSUserDefaults standardUserDefaults] arrayForKey:@"timeCaptured"]];
NSDateFormatter *timeText=[[NSDateFormatter alloc] init];
[timeText setDateFormat:@"HH:mm:ss"];
NSString *timeValue=[timeText stringFromDate:now];
[timeSaved addObject:timeValue];
[[NSUserDefaults standardUserDefaults] setObject:dateSaved forKey:@"dateCaptured"];
[[NSUserDefaults standardUserDefaults] setObject:timeSaved forKey:@"timeCaptured"];
[dateSaved release];
dateSaved=nil;
[timeSaved release];
timeSaved=nil;
int counter = [[NSUserDefaults standardUserDefaults] integerForKey:@"LaunchesCounter"];
counter++;
[[NSUserDefaults standardUserDefaults] setInteger:counter forKey:@"LaunchesCounter"];
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSString *localFilePath = [documentsDirectory stringByAppendingPathComponent:[NSString stringWithFormat:@"image%d.png",counter]];
NSData *thedata = [[NSData alloc] initWithData:UIImagePNGRepresentation(imageToCrop)];
[thedata writeToFile:localFilePath atomically:YES];
[thedata release];
[NSThread detachNewThreadSelector:@selector(processOcrAt:) toTarget:self withObject:[self.imageCropper getCroppedImage]];
}
else{
isCancelled=FALSE;
}
}
ご覧のとおりUIAlerView
、関数の開始時に表示しています。しかし、表示されるまでに時間がかかりすぎます。この問題を解決するための提案はありますか? よろしくお願いします