Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 05-03-2010, 09:41 AM   #1 (permalink)
Registered Member
 
Whitehk's Avatar
 
Join Date: Feb 2010
Posts: 119
Whitehk is on a distinguished road
Default UIImagePickerController not working in landscape.

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!

Last edited by Whitehk; 05-03-2010 at 09:42 AM. Reason: Forgot something.
Whitehk is offline   Reply With Quote
Old 05-03-2010, 12:12 PM   #2 (permalink)
almostfunnydev
iPhone Dev SDK Supporter
 
rocotilos's Avatar
 
Join Date: Oct 2009
Age: 34
Posts: 3,015
rocotilos is on a distinguished road
Default

Yep. My app was rejected because it displayed imagepicker in landscape.

I devise a choppy hack and the app was approved. but, the hack is not good, despite it is easy to implement. most users are annoyed with this hack. i heard if u upgrade to SDK 3.0+, the app will auto rotate to portrait if you select the picker in landscape. But i cannot verify this since am still using 2.2.1.

Here is my hack posted at my blog:
XCode Noobie Tutorials: How To Use UIImagePickerController In Landscape App

HTH.
rocotilos is offline   Reply With Quote
Old 05-03-2010, 02:36 PM   #3 (permalink)
Registered Member
 
Whitehk's Avatar
 
Join Date: Feb 2010
Posts: 119
Whitehk is on a distinguished road
Default

Thanks for the "hack." I might have to eventually resort to that. But for now, does anyone know how to make it automatically rotate to Portrait?
Whitehk is offline   Reply With Quote
Old 05-03-2010, 03:52 PM   #4 (permalink)
Registered Member
 
Whitehk's Avatar
 
Join Date: Feb 2010
Posts: 119
Whitehk is on a distinguished road
Default

Quote:
Originally Posted by rocotilos View Post
Yep. My app was rejected because it displayed imagepicker in landscape.

I devise a choppy hack and the app was approved. but, the hack is not good, despite it is easy to implement. most users are annoyed with this hack. i heard if u upgrade to SDK 3.0+, the app will auto rotate to portrait if you select the picker in landscape. But i cannot verify this since am still using 2.2.1.

Here is my hack posted at my blog:
XCode Noobie Tutorials: How To Use UIImagePickerController In Landscape App

HTH.
Is there a way I can implement your hack if the view controller I'm trying to do this in isn't the one that's loaded first?
Whitehk is offline   Reply With Quote
Reply

Bookmarks

Tags
landscape, orientation, photo library, portrait, uiimagepickercontroller

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 336
20 members and 316 guests
Abidullah, baja_yu, cgokey, Domele, Duncan C, Fstuff, gbenna, givensur, guusleijsten, HowEver, jbro, mdpauley, n00b, newDev, Sami Gh, seokwon lee, SLIC, stanny, Steven.C, WheyLabs
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,648
Threads: 94,113
Posts: 402,877
Top Poster: BrianSlick (7,990)
Welcome to our newest member, brandon6031
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 07:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0