【发布时间】:2015-10-09 10:54:23
【问题描述】:
我有一个图像裁剪函数,它带有一个返回裁剪图像和 CGRect 的委托方法。如何在另一个函数中的自定义完成块中返回它?
有没有办法引用该块,以便我可以在另一个函数中使用它?
很难解释,但这是我的代码:
- (void)cropImage:(UIImage *)image type:(NSInteger)type target:(id)target complete:(cropComplete)complete {
CGFloat ratio;
switch (type) {
case 1:
//16:9
ratio = 16/9.0;
break;
case 2:
//4:3
ratio = 4/3.0;
break;
case 3:
//1:1
ratio = 1;
break;
default:
break;
}
ImageCropViewController *vc = [ImageCropViewController new];
vc.delegate = self;
vc.imageToCrop = image;
vc.ratio = ratio;
UIViewController *targetVC = (UIViewController *)target;
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
[targetVC presentViewController:nav animated:YES completion:nil];
}
//this is the delegate from ImageCropViewController above
- (void)doneCropping:(UIImage *)croppedImage rect:(CGRect)rect {
(I want the image and CGRect here to return in the ^cropComplete block above)
}
【问题讨论】:
标签: ios objective-c protocols block