3

正如您在此视频中看到的那样,每当我尝试裁剪或移动裁剪框时,它都会反弹。我找不到任何方法来做到这一点,我认为我的代码是正确的。我该怎么做?

- (void)viewDidLoad {
  [super viewDidLoad];
  // Do any additional setup after loading the view, typically from a nib.
  if (![UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera]) {
    UIAlertView *myAlertView = [[UIAlertView alloc] initWithTitle:@"Error"
                                                          message:@"Device has no camera"
                                                         delegate:nil
                                                cancelButtonTitle:@"OK"
                                                otherButtonTitles: nil];
    [myAlertView show];
  }
}

- (IBAction)takePhoto:(UIButton *)sender {
  UIImagePickerController *picker = [[UIImagePickerController alloc] init];
  picker.delegate = self;
  picker.allowsEditing = YES;
  picker.sourceType = UIImagePickerControllerSourceTypeCamera;
  [self presentViewController:picker animated:YES completion:NULL];
}

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
  UIImage *chosenImage = info[UIImagePickerControllerEditedImage];
  self.imageView.image = chosenImage;
  [picker dismissViewControllerAnimated:YES completion:NULL];
}
4

1 回答 1

0

如果图像太远,请使用此方法将其动画化:

[UIView animateWithDuration: animations: completion:]

动画:是一个块,如果你想改变你添加的图像位置,它会在一段时间内改变,例如 CGRects[image setRect:(CGRectMake(orginPosition.x, orginPosition.y, size.width, size.height))];

完成:是一个块,但不是必需的。

于 2013-07-20T13:21:58.523 回答