안녕하세요, 내 장치에서 내 서버에 이미지를 업로드하고 있지만 서버에 업로드 된 후 충돌이 발생합니다. 코드에서 나는 이미지를 업로드 한 후이 코드를 추가 한 후 메인 뷰로 돌아 가야하는 것과 같은 조항을 제공했습니다.
코드 업로드 ..
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=nil
대신 대체해야합니다.delegate=self
UIAlertView *alert = [[UIAlertView alloc]initWithTitle:@"Sorry" message:@"your image exceeds more then 4mb pls upload below 4mb image" delegate:nil cancelButtonTitle:@"ok" otherButtonTitles:nil, nil];
[alert show];
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다