Photo Picker app has same issue! - iphone

This is related to my previous thread, but opened a new one here as it involves Apple's own sample code.
Open the sample code and modify the app so it will display in landscape and add a textfield to the view.
Run the app and open the image picker, select an image and you will be returned to the previous screen in landscape as you would expect.
Now tap the text field and see the keyboard scroll into view....in portrait mode?
This happens on the iPad not the iPhone, what gives????
link text

I have found the answer on this forum :-)
"The keyboard will show up in the orientation of the statusbar, which doesn't always change with rotations for some reason. So if you want to display that view only in landscape set [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; or whichever orientation you want to prefer in your viewWillAppear method."
Although why it does not do this on the iPhone ????

Related

iPhone rotation and full-screen video

I've encountered a strange issue, which I need help resolving. My app is always run in portrait mode - I explicitly want it to be that way. In one place in the app I have a UIWebView, which works just fine, as expected. This web view is not shown all the time but is dynamically added to the main view and removed based on user actions (i.e. it's only visible when I need it to).
Now, sometimes in this view I may have a youtube video. The WebView simply contains the <iframe> for the youtube embed. When a user clicks on the video preview frame in the webview, a full-screen video viewer is launched to play the video - which is just fine.
However if during the playback the user rotates the phone, the full-screen video player is rotated and the video is played in landscape mode. Now the video is stopped and the user presses "Done" button without rotating the phone back to portrait mode, the video player is closed and the user returns to my app - however now my layout is also rotated! Not just the video view, but the entire layout - with toolbar, navigation controller, etc.
I don't want any rotation! I just want everything in my app to remain in portrait mode! Moreover, now even if the phone is rotated back to portrait, the app stays in landscape mode.
Note that I only tested this in a simulator so far, as I currently don't have a physical phone to test. I created a simple (bad quality!) video (just filmed the simulator on my screen with an old phone camera) to demonstrate the issue - the video is here: http://shchuka.com/hosting/rotation_problem.mp4
Any ideas what I can do about it?
Add this in, or change it:
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return (UIInterfaceOrientation == UIInterfaceOrientationPortrait);
}
That will prevent all rotation and the app will only work in portrait mode. You can place the return statement within IF statements to allow rotation under certain circumstances.
I sometimes add views to the appDelegate window when I want them to be above everything else, and an annoying side-effect has been that I have to explicitly call my own rotation code as there is no VC as such to deal with it. On the plus side, it might mean that it could be ideal for your needs -
[[[[UIApplication sharedApplication] delegate] window] addSubview:myWebView];
...depending on your app's orientation, etc, before you load the view in the first place, you might need to rotate the webView before displaying it.

UIImagePickerController camera view overlay based on rotation

I want to notify users to take photos only in landscape mode.
I got idea to put some overlay on camera view and if iPhone is in portrait mode to put some label with text "Use landscape mode instead of portrait".
Is it posible? Do you have some advice how to make this posible?
You can have Text (label) on your overlay form (with the note). In the UIImagePickerController delegate check for orientation using , UIInterfaceOrientationIsLandscape and unhide (hide) the text.
I prefer displaying the text through out (irrespective of orientation) to the user for better user experience.

iPhone Game Landscape Orientation Issue

I am trying to make a simple iPhone game and I need the game to be in landscape mode. I can get the initial view to be landscape, but if remove the initial view and replace it with a new view (going from Main Menu to Game Screen) the new view is now in portrait mode. Also, if I switchback to the first view (removing the game screen and then creating the new menu view) the view is still in portrait mode. I have the Info.plist file set up correctly to initialize with landscape right and I have the GameViewController.m file set up with the following code:
-(BOOL) shouldAutorotateToInterfaceOrientation:
(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation == UIInterfaceOrientationLandscapeRight);
}
I have read many postings about people having troubles with setting up the landscape orientation, but they always seem to be about the initial load of the app (only displaying one view). I can't seem to find any solutions for this problem. Can someone help me?
You have stumbled on to
one of the most famous bugs on the platform!
Congratulations for spotting it! Here:
iPhone app in landscape mode, 2008 systems
be sure to read the paragraph that begins: "An important reminder of the ADDITIONAL well-known problem at hand here......." !!
It gives you the solution, which is used in all apps.
Make sure that all the view controllers that are visible on screen support the landscape orientation. I would recommend, in your shouldAutorotateToInterfaceOrientation, to return UIInterfaceOrientationIsIsLandscape(interfaceOrientation); instead of your code. This will ensure that both landscape orientation will work. Can you share a bit more how you are switching from the main menu to the game screen?

Display launch image in Landscape Mode?

I am using Cocos2d and Xcode 4. My app currently displays the launch image in portrait mode, then switches to landscape so the image is on its side, then launches the app. How can I:
1. Make it run the launch image for a certain duration.
2. Make it display it in Landscape mode, not portrait.
Any Help is appreciated. Thanks!
Can't you just make your image in landscape and use that? Basically like what zeiteisen said.
Just open up gimp or photoshop and make a new image: 480w X 320h.
To make your launch image display in landscape mode, simply append -Landscape to its filename (e.g. change LaunchImage.png to LaunchImage-Landscape.png).
As for showing your launch image for a certain duration, you have two options: display a "launch image" view controller initially and dismiss it after the desired duration (allows you to fade the image out, etc.), or simply call sleep() in your app delegate's application:didFinishLaunchingWithOptions:. It's important to note that you have no control over how long the OS displays your launch image before control is passed to your app delegate—you need to take this into consideration.
Just rotate the Default.png in your favourite image editor like Photoshop.
I had a similar problem and fixed it by changing the view to landscape in Interface Builder. Mine is still animating though from the initial portrait orientation of the Window (not settable to landscape in IB).
In AppDelegate applicatio:didFinishLaunchingWithOptions there is a call to
[director_ pushScene: [IntroLayer scene]]. In there, it shamelessly loads the splash screen again and displays it rotated by 90 degrees:
if( UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone ) {
background = [CCSprite spriteWithFile:#"Default.png"];
background.rotation = 90;
}
Removing this fixes the rotating splash screen problem.

UIImagePickerController differences from iPhone and iPad woes

I have an app designed for iPhone that makes use of the UIImagePickerController.
The app run in landscape only up until the image picker comes into view in its default portrait.
Problem 1:
On the iPhone when I rotate the device to portrait to view the image library the image picker view seems to do a flip as if rotating from landscape to portrait?
Problem 2:
I get the dreaded warning Using two-stage rotation animation. To use the smoother single-stage animation, this application must remove two-stage method implementations.
Problem 3.
on the iPad when selecting an image the image picker is dismissed and the view is back in landscape but ...... if I then do anything that requires alert view or the keyboard they appear as if the device is in portrait? This does not happen on the iPhone???
I know problem 2 is a long running issue but please can anyone help with problems 1 & 3?
Thanks
number 3 resolved :-)
"The keyboard will show up in the orientation of the statusbar, which doesn't always change with rotations for some reason. So if you want to display that view only in landscape set [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeLeft; or whichever orientation you want to prefer in your viewWillAppear method."