【问题标题】:move and scale bounces back移动和规模反弹
【发布时间】:2013-07-19 17:05:35
【问题描述】:

正如您在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];
}

【问题讨论】:

  • 我已经更新了我的答案,所以初学者可以理解。

标签: ios objective-c uiviewanimation


【解决方案1】:

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

[UIView animateWithDuration: animations: completion:]

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

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

【讨论】:

  • 你可以在放开图像时使用勾股定理,如果勾股定理比你想要的长,使用上面的方法......我不需要解释如何使用它,它非常简单
  • @arbitur,我不相信您理解所提出的问题。问题与UIImagePickerController 编辑界面的工作原理有关。与UIView动画无关。
  • 是的,它正在使用 UIImagePickerController
  • 我认为问题是关于如何让 UIImageView 与 UIImagePickerController 捕获的 UIImage 在拖得太远时反弹回来。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-05-25
  • 1970-01-01
  • 2013-03-21
  • 1970-01-01
  • 2021-11-27
相关资源
最近更新 更多