我希望在拍摄照片时为iPhone相机图像提供缩放效果。缩放效果应该是当前图像的特定部分。此效果应在捕获图像之前。
对于示例我创建了UIImagePickerController的两个对象,代码在
下面.h文件
UIImagePickerController *imagePicker_obj1,imagePicker_obj2;
UIScrollView *scrollView_obj1,*scrollView_obj;
.m文件
imagePicker_obj1 = [[UIImagePickerController alloc]init];
imagePicker_obj2 = [[UIImagePickerController alloc]init];
imagePicker_obj1.delegate = self;
imagePicker_obj2.delegate = self;
if ([UIImagePickerController isSourceTypeAvailable:UIImagePickerControllerSourceTypeCamera])
{
imagePicker_obj1.sourceType = UIImagePickerControllerSourceTypeCamera;
imagePicker_obj2.sourceType = UIImagePickerControllerSourceTypeCamera;
}
else
exit(1);
scrollView_obj1 = [[UIScrollView alloc]initWithFrame:CGRectMake(50.0, 250.0, 200.0, 200.0)];
[window addSubview:scrollView_obj1];
scrollView_obj1.contentSize = CGSizeMake(imagePicker_obj1.view.frame.size.width, imagePicker_obj1.view.frame.size.height);
scrollView_obj1.maximumZoomScale = 4.0;
scrollView_obj1.minimumZoomScale = 0.75;
scrollView_obj1.clipsToBounds = YES;
scrollView_obj1.delegate = self;
[scrollView_obj1 addSubview:imagePicker_obj1.view];
scrollView_obj = [[UIScrollView alloc]initWithFrame:CGRectMake(50.0, 0.0, 200.0, 200.0)];
[window addSubview:scrollView_obj];
[scrollView_obj setBackgroundColor:[UIColor clearColor]];
scrollView_obj.contentSize = CGSizeMake(imagePicker_obj2.view.frame.size.width, imagePicker_obj2.view.frame.size.height);
scrollView_obj.maximumZoomScale = 4.0;
scrollView_obj.minimumZoomScale = 0.75;
scrollView_obj.clipsToBounds = YES;
scrollView_obj.delegate = self;
[scrollView_obj addSubview:imagePicker_obj2.view];
在此之后我期望UIImagePickerController
的两个不同对象给出相同的输出,并且两个滚动视图的内容将是相同的。
但是我只得到UIImagePickerController
的一个对象的输出,另一个是空白的。
有人可以解释出现了什么问题吗?
答案 0 :(得分:0)
由于您只有一台摄像头,我希望在这种情况下只能使用一个UIImagePickerController
控制器。
答案 1 :(得分:0)
第二个UIImagePickerController无法抓取相机,因为第一个UIImagePickerController上有一个独占锁。