버튼을 누르면 경고보기가 표시됩니다. 표시되지만 화면에 표시하는 데 너무 많은 시간이 소요됩니다. 여기에 내가 버튼을 눌러 촉구하고있는 기능은 다음과 같습니다 당신은 내가 함수의 시작 부분에 UIAlerView
을 표시하고 있음을 볼 수 있듯이UIAlertView 표시 시간이
-(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;
}
}
. 그러나 그것은 표시 되기에는 너무 오래 걸리고 있습니다. 이 문제를 해결하기위한 제안 사항이 있으십니까? 감사 감사 이드리스
, 당신은 [thedata writeToFile가 : localFilePath 원자 적 : YES] 메인 스레드'에 파일로 작성되기 때문에,' – Nekto
그러나 파일에 쓰기 전에, 내가 UIAlertView 표시하고 있습니다. 그리고 약간의 시간이 지나면 표시됩니다. –