ios - RSKImageCropper 无法快速配置

标签 ios objective-c swift

我想使用一个名为 RSKImageCropper 的小型库来裁剪图像 但是当我想调用它时什么也没有发生......甚至没有崩溃

我已经像在 objective-c 示例中一样实现了一切

这是示例中的 objective-c 代码:

#pragma mark - Action handling

- (void)onAddPhotoButtonTouch:(UIButton *)sender
{
    UIImage *photo = [UIImage imageNamed:@"photo"];
    RSKImageCropViewController *imageCropVC = [[RSKImageCropViewController alloc] initWithImage:photo cropMode:RSKImageCropModeCircle];
    imageCropVC.delegate = self;
    [self.navigationController pushViewController:imageCropVC animated:YES];
}

#pragma mark - RSKImageCropViewControllerDelegate

- (void)imageCropViewControllerDidCancelCrop:(RSKImageCropViewController *)controller
{
    [self.navigationController popViewControllerAnimated:YES];
}

- (void)imageCropViewController:(RSKImageCropViewController *)controller didCropImage:(UIImage *)croppedImage usingCropRect:(CGRect)cropRect
{
    [self.addPhotoButton setImage:croppedImage forState:UIControlStateNormal];
    [self.navigationController popViewControllerAnimated:YES];
}

@end

这是我的代码:

class ViewController:  UIViewController, RSKImageCropViewControllerDelegate {


    @IBAction func addPhoto(sender: UIButton) {
        let image = UIImage(named: "picture")!
        let controller: RSKImageCropViewController = RSKImageCropViewController(image: image)
        controller.delegate = self
        self.navigationController?.pushViewController(controller, animated: true)
}
    func imageCropViewControllerDidCancelCrop(controller: RSKImageCropViewController) {
        self.navigationController?.popViewControllerAnimated(true)
    }

    func imageCropViewController(controller: RSKImageCropViewController, didCropImage croppedImage: UIImage, usingCropRect cropRect: CGRect) {
        self.navigationController?.popViewControllerAnimated(true)
    }

    override func viewDidLoad() {


    }
}

最佳答案

检查您的 ViewController 是否必须嵌入到 UINavigationController 中。因为根据您的代码,您的 View Controller 正在尝试推送 RSKImageCropViewController 对象。

关于ios - RSKImageCropper 无法快速配置,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34417048/

相关文章:

ios - iTunes Connect 中的 App Icon 会覆盖 iTunesArtwork.png 图片吗?

ios - TouchId 身份验证 - 删除警报

ios - MessageComposeViewController 不调用委托(delegate)

iphone - iOS 内存泄漏导致更改 View Controller 时崩溃

ios - 如何让 UIManagedDocument 显示为文件包而不是文件夹

iOS:从 Crashlytics 了解 SIGABRT 崩溃

iphone - 在 iOS 中获取触摸位置时,PAN 手势崩溃

ios - URLSession 结果为 NIL 数据

ios - 升级 Firebase 破坏了我的 iOS 项目

iPhone : Textfields and NSNumberFormatter