Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/objective-c/25.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 移动和缩放会反弹回来_Ios_Objective C_Uiviewanimation - Fatal编程技术网

Ios 移动和缩放会反弹回来

Ios 移动和缩放会反弹回来,ios,objective-c,uiviewanimation,Ios,Objective C,Uiviewanimation,正如您可以看到的,每当我尝试裁剪或移动裁剪框时,它都会反弹。我找不到任何方法来做到这一点,我认为我的代码是正确的。我该怎么做呢 - (void)viewDidLoad { [super viewDidLoad]; // Do any additional setup after loading the view, typically from a nib. if (![UIImagePickerController isSourceTypeAvailable:UIImagePicke

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

- (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:]
动画:是一个块,如果要更改添加的图像位置,它将在一段时间内更改,例如CGRects
[image setRect:(CGRectMake(orginPosition.x,orginPosition.y,size.width,size.height))


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

当你放开图像时,可以使用勾股定理,如果勾股定理比你想要的长,则使用上述方法。。。我不需要解释如何使用它,它非常有用simple@arbitur,我相信你不明白这个问题。问题与
UIImagePickerController
编辑界面的工作方式有关。它与
UIView
动画无关。是的,它使用的是UIImagePickerController。我想问题是如何让UIImageView与UIImagePickerController捕获的UIImage在拖得太远时反弹。我更新了我的答案,让初学者能够理解。