I have to present an alertview when my app starts. My app supports both landscape modes.
Despite the landscape mode the device is when the app starts the alertview always shows in portrait.
I have tried to use the accelerometer to detect the interface orientation before the orientation notification and I have the correct orientation 2 seconds before the alertview showing.
Then, I use this code to set the status bar to a different orientation, hoping the alertview will follow...
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationLandscapeRight];
or left, depending on the landscape mode.
Nothing works.
Is there a way to force the alertview to respect the orientation?
The point here is this: I cannot set one landscape orientation in particular for the status bar, I have to detect the orientation the device is on and then set the status bar orientation.
thanks for any help.
Is your app using a UITabBarController or a UINavigationController?? Try calling the alert from the rootViewController , which may be a UITabBarController or any other rootController.
Dont show the alert from the immediate screen (or subview). Call [alert show] by overriding UITabBarController and from inside it.
i hope I got your problem right
Cheers,
Harikant Jammi
Related
I have two viewcontrollers, ViewControllerA supports both landscape and portrait, click a button in ViewControllerA push into ViewControllerB, which supports landscape only, then I make the phone in the landscape direction and then pop back to ViewControllerA, by default A is in landscape mode now, but I want it to be portrait first in this situation. How can I implement that?
In your ViewControllerA's viewwillappear method set the orientation like
[[UIDevice currentDevice]setOrientation:UIInterfaceOrientationPortrait];
I have added MPMoviePlayerController in my view. and its working fine. and when I switch to this in full screen and change the orientation of device then no orientation change event is fired. so please can let me know how I solve this issue.
Thanks
I suppose you present MPMoviePlayerController modally so check out the -
(void)shouldAutorotateToInterfaceOrientation: method of your main app controller. I suppose that if you return TRUE just for portrait the modal controller can't rotate itself. Try to return TRUE for all interface orientation on your rootViewController and the MPMoviePlayerController should start to rotate.
In my app, While playing video user can play in full screen in both orientation landscape and portrait. But while move back to original position from full screen, i want to change my controller's orientation to portrait if its running in landscape.
Its working fine if i push that controller, but i have to present it. So its not working with presented controller.
I m using code as below to make it portrait.
[appdel.navigationController.presentedViewController.view removeFromSuperview];
[[UIApplication sharedApplication] setStatusBarOrientation:UIInterfaceOrientationPortrait];
[[UIApplication sharedApplication].self.delegate.window addSubview:[appdel.navigationController.presentedViewController.view];
self.navigationController.navigationBar.hidden=NO;
Thanks for any help
see in case of presenting the controller when u come in previous controller the
viewWillApear: of previous method will call so change your orientation in viewWillApear: mthod
I have a UITabBar with 2 bar items. The initial orientation of the device is portrait. If I rotate the device to landscape while being at tabBarItem2 the whole thing(Status Bar, TabBar, ViewContent2) rotates fine, but when I press the tabBarItem1 the ViewContent1 is still in Portrait. It also happens if I'm in tabBarItem1, then rotate device to landscape and I go to tabBarItem2.
I'm using the willRotateToInterfaceOrientation method on each view controller to move things.
I think this is happening because it is triggering the actual viewController's willRotateToInterfaceOrientation method and not on both of them.
Any ideas on how to fix that?
Both view controllers need to have
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
return YES;
}
I am making an universal app, but only support rotation on iPad so here it goes:
I have a view that has a image as background. When the user rotates the iPad I fade this portrait image out in the willRotateToInterfaceOrientation and replaces the image with a landscape image in didRotateFromInterfaceOrientation, and this is working great! (If there are better ways I want to hear them, but this question is not about this though).
I have one button on this view that will push a new viewcontroller on the stack. This view controller also has the same "function" as the view that it was pushed from. What I need help with is: When I rotates the iPad from portrait (which was the orientation this view was pushed on from) to landscape the image in this "second" view changes as intended. However when I pop this viewcontroller off stack the "first" view still displays the image which is made for portrait and not the landscape one...I understand why but not how I should fix this.
Could anyone help me. Thank you for your time.
You can save the device orientation (check UIDevice documentation) on your viewWillDisappear: and check it on the viewWillAppear: method, calling the animation if necessary.
(the OP told me to post it as answer)
You could always register for UIDeviceOrientationDidChangeNotification and change the image if the controller is not on the top stack.
Assuming you're using a UINavigationController (since you mentioned pushing controllers), you could figure out if the controller is on top by:
if ([[self navigationController] topViewController] == self) {
// do magic
}
Use the first view controller's viewWillAppear method. In there, you can find the device's orientation by calling [[UIDevice currentDevice] orientation] and set the background image accordingly.