正如您在 this video 中看到的那样每当我尝试裁剪或移动裁剪框时它都会反弹。我找不到任何方法来做到这一点,我认为我的代码是正确的。我该怎么做?
- (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];
}
最佳答案
如果图像距离太远,请使用此方法将其动画化:
[UIView animateWithDuration: animations: completion:]
动画:是一个 block ,它会在一段时间内改变,例如 CGRects,如果你想改变你添加的图像位置 [image setRect:(CGRectMake(orginPosition.x, orginPosition.y, size.width,尺寸.高度))];
完成:是一个 block ,但不是必需的。
关于ios - 移动和缩放反弹,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17762574/