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 with
didRotateFromInterfaceOrientation 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
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.