-1
我想上傳UIImage
到網站。我已經實現了一些代碼。我已經從第一頁選擇圖片並在第二頁上傳。在此處----- [body appendData:[NSData dataWithData:_imgData]]; ---- _imgData變爲零。在這裏輸入代碼我已經寫了一些代碼,但我不知道我的錯誤在哪裏。上傳圖片到網絡服務器
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];
}
}
什麼是你的問題吧? – Eiko
對不起,我們不想猜測你的錯誤。投票結束。 – Eiko