iPad 相机覆盖方向问题
我正在为 iPad2 开发一个应用程序,允许用户拍照。我将使用图像选择器的自定义覆盖。但此覆盖视图无法检测设备的方向。
我尝试过 didRotateFromInterfaceOrientation
和 willAnimateRotationToInterfaceOrientation
。但他们都没有工作。这就是我创建叠加层的方式。
@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];
}
}
}
谁能告诉我如何检测相机覆盖范围内设备的旋转?
非常感谢
I am developing an app for iPad2 which allows user to take photos. I am going to use custom overlay for image picker. But this overlay view does not detect the orientation of the device.
I have tried withdidRotateFromInterfaceOrientation
and willAnimateRotationToInterfaceOrientation
. But non of them are working. This is how I am creating overlay.
@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];
}
}
}
Can anyone please tell me how can I detect the rotation of the device within camera overlay?
Many thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我自己解决了上述问题。
上面的函数已经像这样重新创建了。
然后我使用导航控制器委托。在此功能中,我可以捕获设备方向并解决我的问题。
感谢您查看此内容。
I have solove above issue by myself.
The above function has been recreated like this.
Then I have use navigation controller delegate. Within this function I could capture the device orientation and solved my issues.
Thanks for viewing this.