views:

682

answers:

1

Hello everyone!

Here is my situation. I am creating a landscape based app and doing all my testing on iPhone OS 2.2.1. In one section of the app, the user has to either click a picture using the camera or select a picture from the photo album. Obviously, I used the UIImagePickerController to get this done. But I am facing a very serious issue, the solution to which I haven't been able to find on the internet. The code I have written to take care of this issue work perfectly on iPhone OS 3.0, but it doesn't seem to work on OS 2.2.1.

What my code basically does is this. On pressing an 'Add Photo' button, the UIImagePicker view controller is pushed in and this automatically appears in portrait orientation. My imagePickerController: didFinishPickingImage: editingInfo: method is given below -

-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingImage:(UIImage *)image editingInfo:(NSDictionary *)editingInfo {
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
[[picker parentViewController] dismissModalViewControllerAnimated:YES];
addPhotoView = [[UIImageView alloc] initWithImage:image];
[addPhotoView setFrame:CGRectMake(190.0, 20.0, 120.0, 120.0)];
[self.view addSubview:addPhotoView];

}

Basically, this method sets the status bar orientation back to UIInterfaceOrientationLandscapeRight and adds the picture to the UIImageView in my view. This makes my app work just the way I want it to. Again I repeat, this code only works in iPhone OS 3.0.

When I use this same code and try to build for iPhone OS 2.2.1, my Photo Album and Camera open up in the landscape mode. Due to this, the thumbnails of pictures in the photo album appear stretched and distorted as to fit the whole screen. And the camera view does not fit onto the screen. On manual rotation of the device, the photo album and camera automatically rotate to the normal portrait orientation. But when I exit from this view, my original app view also appears rotated, which ideally should not happen as my app is a completely landscape app. Here are a few pictures of what I'm trying to explain -

  1. On pressing the 'Add Photo' button to select a picture from the Camera Roll Album - http://img200.imageshack.us/i/picture2gjd.png/ (since new users aren't allowed to use image tags just click this link to see what I mean) :)

I was wondering if there is a way to accomplish what I'm trying to achieve in OS 2.2.1. To summarize, this is what I want to do - - On pressing the 'Add Photo' button, I want my UIImagePickerController to display its view in the portrait, NOT landscape, style. - After exiting the portrait style view of the UIImagePickerController, my app should remain in the landscape orientation and not rotate to the portrait style too.

I look forward to hearing from you guys! Thanks!

A.K.

+1  A: 

Did you find a solution to this issue?

Ben
Well I wasn't able to find a solution to the issue, but I was able to devise a hack to get it done. I just created a new UIWindow object and loaded the UIImagePickerController onto that window. This displayed in portrait mode and things worked fine, but the code got a little messy. Moreover, having more than one window in an app is illegal according to the iPhone App Guidelines.But don't lose faith guys, this has been done by EA in their game Spore and since the app has been approved by Apple, I guess they have followed a 100% legal way. I'm still wrapping my brain around how EA did it..
AK