iPad摄像头覆盖方向问题
我正在为iPad2开发一个允许用户拍照的应用程序。我将使用自定义覆盖图像选择器。但该叠加视图无法检测设备的方向 我试过了 DidRotateFromInterface定向和WillAnimateRotationInterface定向。但他们中没有一个人在工作。这就是我如何创建覆盖iPad摄像头覆盖方向问题,ipad,camera,orientation,overlay,uiimagepickercontroller,Ipad,Camera,Orientation,Overlay,Uiimagepickercontroller,我正在为iPad2开发一个允许用户拍照的应用程序。我将使用自定义覆盖图像选择器。但该叠加视图无法检测设备的方向 我试过了 DidRotateFromInterface定向和WillAnimateRotationInterface定向。但他们中没有一个人在工作。这就是我如何创建覆盖 @interface CameraOverlayController : UIViewController <UINavigationControllerDelegate, UIImagePickerContro
@interface CameraOverlayController : UIViewController <UINavigationControllerDelegate, UIImagePickerControllerDelegate>
-(void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType
{
self.picker.sourceType = sourceType;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
self.picker.showsCameraControls = NO;
if ([[self.picker.cameraOverlayView subviews] count] == 0)
{
CGRect overlayViewFrame = self.picker.cameraOverlayView.frame;
if (UIDeviceOrientationIsLandscape(self.interfaceOrientation)) {
NSLog(@"Initially Landscape and height : %f" , CGRectGetHeight(overlayViewFrame));
}
if (UIDeviceOrientationIsPortrait(self.interfaceOrientation)) {
NSLog(@"Initially Portrait and height : %f", CGRectGetHeight(overlayViewFrame));
}
self.view.backgroundColor = [UIColor clearColor];
CGRect newFrame = CGRectMake(0.0, CGRectGetHeight(overlayViewFrame) - self.view.frame.size.height - 10.0, CGRectGetWidth(overlayViewFrame), self.view.frame.size.height + 10.0);
self.view.frame = newFrame;
[self.picker.cameraOverlayView addSubview:self.view];
}
}
}
有人能告诉我如何在摄像机覆盖范围内检测设备的旋转吗
非常感谢我自己解决了上述问题。 上面的函数是这样重新创建的
-(void)setupImagePicker:(UIImagePickerControllerSourceType)sourceType
{
self.picker.sourceType = sourceType;
if (sourceType == UIImagePickerControllerSourceTypeCamera)
{
self.picker.showsCameraControls = NO;
}
}
然后我使用导航控制器代理。在这个功能中,我可以捕捉设备方向并解决我的问题
-(void)navigationController:(UINavigationController *)navigationController willShowViewController:(UIViewController *)viewController animated:(BOOL)animated
谢谢您的收看。您好,您能详细解释一下吗?你能告诉我你是如何实现willShowViewController的吗?感谢此willShowViewController是导航控制器委托。在此方法中实现所有UI navigationController工具栏、按钮等,并将其作为子视图添加到viewController中。我希望这会对你有所帮助。@Chinthaka:嗨……我已经创建了一个自定义相机,在肖像模式下,实时屏幕可以很好地加载。但当我将其更改为横向模式时,我在控制台CGAffineTransformInvert:singular matrix中得到了这个错误。我试着用自动调整大小的蒙版来改变屏幕的方向,但是没有用。你能把你的代码贴在我可以看的地方吗?或者你可以把问题单独贴出来,任何人都可以回答。