-1
웹 사이트에 UIImage
을 업로드하고 싶습니다. 일부 코드를 구현했습니다. 첫 번째 페이지에서 이미지를 선택하고 두 번째 페이지에 업로드했습니다.이 중 ----- [body appendData : [NSData dataWithData : _imgData]]; ---- _imgData는 nil이됩니다. 여기에 코드를 입력하십시오. 이미 일부 코드를 작성했지만, 제 실수는 어디 있는지 모르겠습니다.이미지를 웹 서버에 업로드
My Code is:
-(void)ImgaeCropped:(UIImage *)image
{
_imageView.image=image;
Register2 *reg2=[self.storyboard instantiateViewControllerWithIdentifier:@"Register2"];
// reg2.self.selected_image=_imageView.image;
reg2.imgData=imageData;
picture_view.hidden=YES;
}
- (void)imagePickerController:(UIImagePickerController *) Picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
@try {
// transparent_view.hidden=YES;
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
indicator.frame=CGRectMake(0, 0, 10, 10);
indicator.center = CGPointMake(CGRectGetMidX(_imageView.bounds), CGRectGetMidY(_imageView.bounds));
[_imageView addSubview:indicator];
[indicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[indicator setColor:[UIColor grayColor]];
[indicator startAnimating];
[self dismissViewControllerAnimated:YES completion:^ {
[indicator removeFromSuperview];
[indicator stopAnimating];
CropViewController *crop=[self.storyboard instantiateViewControllerWithIdentifier:@"CropViewController"];
crop.cropDelegate=self;
crop.image=[info objectForKey:UIImagePickerControllerOriginalImage];
// UIImageView *imgvUserImage = [[UIImageView alloc]init];
UIImage *imgvUserImage= [info objectForKey:UIImagePickerControllerOriginalImage];
imageData=UIImageJPEGRepresentation(imgvUserImage, 0.9);
[self presentViewController:crop animated:YES completion:nil];
}];
}
@catch (NSException *exception) {
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Finish Picking" message:exception.description delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
// [alert show];
}
@finally {
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Finish Picking" message:@"Final" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
// [alert show];
}
}
And the image selection code is ---------------
-(void)ImgaeCropped:(UIImage *)image
{
_imageView.image=image;
Register2 *reg2=[self.storyboard instantiateViewControllerWithIdentifier:@"Register2"];
// reg2.self.selected_image=_imageView.image;
reg2.imgData=imageData;
picture_view.hidden=YES;
}
- (void)imagePickerController:(UIImagePickerController *) Picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
@try {
// transparent_view.hidden=YES;
UIActivityIndicatorView *indicator = [[UIActivityIndicatorView alloc] initWithActivityIndicatorStyle:UIActivityIndicatorViewStyleGray];
[indicator startAnimating];
indicator.frame=CGRectMake(0, 0, 10, 10);
indicator.center = CGPointMake(CGRectGetMidX(_imageView.bounds), CGRectGetMidY(_imageView.bounds));
[_imageView addSubview:indicator];
[indicator setActivityIndicatorViewStyle:UIActivityIndicatorViewStyleGray];
[indicator setColor:[UIColor grayColor]];
[indicator startAnimating];
[self dismissViewControllerAnimated:YES completion:^ {
[indicator removeFromSuperview];
[indicator stopAnimating];
CropViewController *crop=[self.storyboard instantiateViewControllerWithIdentifier:@"CropViewController"];
crop.cropDelegate=self;
crop.image=[info objectForKey:UIImagePickerControllerOriginalImage];
// UIImageView *imgvUserImage = [[UIImageView alloc]init];
UIImage *imgvUserImage= [info objectForKey:UIImagePickerControllerOriginalImage];
imageData=UIImageJPEGRepresentation(imgvUserImage, 0.9);
[self presentViewController:crop animated:YES completion:nil];
}];
}
@catch (NSException *exception) {
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Finish Picking" message:exception.description delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
// [alert show];
}
@finally {
// UIAlertView *alert = [[UIAlertView alloc] initWithTitle:@"Finish Picking" message:@"Final" delegate:nil cancelButtonTitle:@"OK" otherButtonTitles:nil, nil];
// [alert show];
}
}
그리고 무슨 문제에 AFNetworking를 추가! – Eiko
죄송합니다. 귀하의 오류를 추측하고 싶지는 않습니다. 투표를 종료합니다. – Eiko