我在创建自己的自定义“拍照”按钮时遇到了一些问题。基本上,当我删除默认控件时,摄像机不再执行快门动画或执行编辑过程,直接进入委托方法。UiImagePickerController takePicture问题
所以,这是一些代码。起初,我用的是默认的布局,像这样:
(顺便说一下,我已经打消了我,如果确定硬件可用性报表 - 他们无关。)
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
picker.showsCameraControls = YES;
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
[self presentModalViewController:picker animated:YES];
有了这个代码,当我按下默认的“拍照”按钮时,快门动画将被触发,并显示“移动和缩放”视图。按“选择”后,代表被调用,我可以通过info
访问编辑结果。
所以这里是我的新自定义“拍照”按钮的初始化代码,没有别的;顺便说一下,我这个初始化中的UIImagePickerController我的ViewController
UIImagePickerController *picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
picker.allowsEditing = YES;
UIButton *shoot = [[UIButton alloc] initWithFrame:CGRectMake(110, 420, 100, 40)];
[shoot setTitle:@"Shoot" forState:UIControlStateNormal];
[shoot.titleLabel setTextColor:[UIColor whiteColor]];
[shoot addTarget:picker action:@selector(takePicture) forControlEvents:UIControlEventTouchUpInside];
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
[picker.cameraOverlayView addSubview:shoot];
picker.showsCameraControls = NO;
picker.cameraCaptureMode = UIImagePickerControllerCameraCaptureModePhoto;
[self presentModalViewController:picker animated:YES];
在这个例子中的viewDidAppear方法,当我打我的自定义按钮,没有动画被解雇,没有编辑屏幕所示,委托调用立即。
有趣的是,如果我在上面的示例中将showsCameraControls
属性更改为YES
,我的自定义按钮的行为与第一个示例中默认按钮的行为方式完全相同。
漂亮的难倒在这一个,有什么我需要在didFinishPickingMediaWithInfo
做调用图像编辑器,或者我只是在我的初始化缺少的东西吗?
我使用的Xcode 4.3和iOS 5.1(应用程序是针对5.0)
任何帮助不胜感激;干杯!
在这里有相同的问题。 – eugene 2012-08-11 13:01:53