안녕하세요, 내 서버 양식에 이미지를 업로드하고 있지만 서버에 업로드 된 후 크래시가 발생합니다. 코드에서 이미지를 업로드 한 후이 코드를 추가 한 후 주보기로 돌아 가야하는 것과 같은 조항을 부여했습니다. 계속 충돌합니다. 경고 메시지는 내가 어떻게이 일을 해결하는 방법을 가르쳐주세요 중단됩니다 경고 메시지 응용 프로그램에서 확인을 클릭하면 팝업 후응용 프로그램 서버에 이미지를 업로드 한 후 크래시 받기 IOS7
업로드 코드 ..
NSString *urlString = @"http://indianpoliticalleadersmap.com/IOS/upload/photos/upload.php";
NSData *imageData = UIImageJPEGRepresentation(imageview.image,90);
long imageSize = imageData.length;
NSLog(@"SIZE OF IMAGE: %.2f Mb", (float)imageSize/1024/1024);
if (imageSize > 4.194e+6) {
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Sorry" message:@"your image exceeds more then 4mb pls upload below 4mb image" delegate:self cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
[alert release];
}
else
{
NSString *urlString = @"url";
NSMutableURLRequest *request = [[[NSMutableURLRequest alloc]init]autorelease];
[request setURL:[NSURL URLWithString:urlString]] ;
[request setHTTPMethod:@"POST"];
NSString *boundary = @"---------------------------14737809831466499882746641449";
NSString *contentType = [NSString stringWithFormat:@"multipart/form-data; boundary=%@",boundary];
[request addValue:contentType forHTTPHeaderField:@"Content-Type"];
NSMutableData *body = [NSMutableData data];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@\r\n",boundary]dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Disposition: form-data; name=\"userfile\"; filename=\".jpg\"\r\n"dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[@"Content-Type: application/octet-stream\r\n\r\n"dataUsingEncoding:NSUTF8StringEncoding]];
[body appendData:[NSData dataWithData:imageData]];
[body appendData:[[NSString stringWithFormat:@"\r\n--%@--\r\n", boundary]dataUsingEncoding:NSUTF8StringEncoding]];
[request setHTTPBody:body];
NSData *returnData = [NSURLConnection sendSynchronousRequest:request returningResponse:nil error:nil];
NSString *returnString = [[NSString alloc] initWithData:returnData encoding:NSUTF8StringEncoding];
NSLog(@"%@data",returnString);
[self temp];
[self performSelector:@selector(myMethod) withObject:nil afterDelay:3.0f];
[self performSelector:@selector(dissMissViewController) withObject:self afterDelay:4.0f];
alertTimer = [NSTimer scheduledTimerWithTimeInterval:2 target:self selector:@selector(showAlert) userInfo:nil repeats:NO];
}
}
응용 프로그램은 충돌을 가져옵니다.
-(void)showAlert{
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Thanks" message:@"For uploading Image" delegate:self cancelButtonTitle:nil otherButtonTitles:@"ok", nil];
[alert show];
[alert release];
}
감사합니다.
delegate=self
의 대체해야한다. –@ V-Xtreme 스레드 1로 표시 : EXC_BAD_ACCESS (코드 = 1 address0xc00000c) – user3349668
@ V-Xtreme pls는 내가 지금 업데이트 한 코드를 확인합니다. – user3349668