I am making a camera app for iPad. I want the camera app to work only in portrait mode. I had to put in a rotation observation, and force the device to use portrait mode like this:
UIImagePickerController in Landscape
I think this is private API; some of the users on the post suggested that it is.
If so, what other work around can I use to force the overlay to stay in portrait mode only? If I don't add this code it rotates to both portrait and landscape mode.
//Is this private?
@interface UIDevice ()
-(void)setOrientation:(UIDeviceOrientation)orientation;
@end
-(IBAction)InitiateCamera
{
overlayview = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 768, 1024)];
...
...
//monitor device rotation
[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];
[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(didRotate:) name:UIDeviceOrientationDidChangeNotification object:nil];
//launch camera
[self presentViewController:picpicker animated:YES completion:nil];
}
- (void) didRotate:(NSNotification *)notification
{
//IS THIS PRIVATE?
//Maintain the camera in portrait orientation
[[UIDevice currentDevice] setOrientation:UIInterfaceOrientationPortrait];
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return UIInterfaceOrientationIsPortrait(interfaceOrientation);
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
{
return UIInterfaceOrientationPortrait;
}