Hi. I recently created an app where the user has the choice of picking his own avatar either from his photo library or by taking a picture on the spot. The app is entirely in landscape right. Some places, I've read that the UIImagePickerController should automatically rotate to fit the screen orientation, and others places, I've read it's not even allowed by Apple to have it in anything other than portrait. Any ideas on how I would do this? Or maybe even how I can modify my existing code to work? Here's the code I used:
What happens when the user presses the button:
Code:
-(IBAction) getPhoto:(id) sender {
UIImagePickerController * picker = [[UIImagePickerController alloc] init];
picker.delegate = self;
if((UIButton *) sender == chooseAvatarFromLibrary) {
picker.sourceType = UIImagePickerControllerSourceTypeSavedPhotosAlbum;
} else {
picker.sourceType = UIImagePickerControllerSourceTypeCamera;
}
[self presentModalViewController:picker animated:YES];
}
How I make the UIImagePickerController:
Code:
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
[picker dismissModalViewControllerAnimated:YES];
player.image = [info objectForKey:@"UIImagePickerControllerOriginalImage"];
}
The ShouldAutoRotate Function:
Code:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
What happens with this code is I press the button, it sits and thinks for a little bit, and nothing happens. I tried changing everything to portrait and it worked just fine. Help is always appreciated. Thanks!