i have a portrait view (status bar hidden), but i turned it. Then keyboard shows this:
i want keyboard to turn and fullscreen. Please help me. Thanks in advance.
I have seen the comments.
You can't make the screen be landscape like this. IOS 6 has something new, "the app's appDelegate always start as portrait"
You should use the IOS 6 autorotate!
This should be in the appDelegate:
- (NSUInteger)application:(UIApplication*)application
supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return (UIInterfaceOrientationMaskAll);
}
In your view controller:
-(BOOL)shouldAutorotate
{
return YES;
}
-(NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAll;
}
in the supportedInterfaceOrientations you can set it to landscape only
Related
I've been trying all morning to fix this, to no avail. Here's my situation:
I have a navigation controller across two views in my app. The first view shouldn't rotate away from portrait. The second view should rotate between portrait and landscape. Going back to the first view should send it back to portrait.
Here's the code I have currently (which i've experimented with without success, so is in no way solid):
AppDelegate:
- (NSUInteger)application:(UIApplication*)application
supportedInterfaceOrientationsForWindow:(UIWindow*)window
{
return UIInterfaceOrientationMaskAll;
}
Navigation controller:
- (BOOL)shouldAutorotate
{
return self.topViewController.shouldAutorotate;
}
First view controller:
-(BOOL)shouldAutorotate
{
return NO;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskPortrait;
}
Second view controller:
-(BOOL)shouldAutorotate
{
return YES;
}
- (NSUInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
The current behaviour is that app will stay in portait on the first VC, rotate properly on the second VC, but if I go back while in landscape, the first VC is in landscape and stays there. How can I fix this?
I was having the same issue, and as far as I can remember, you can't fix it due to the way how auto-rotation works. However, I did come up with a workaround - when in landscape mode, I hid the navigation bar, disabling the option to tap the back button. This might or might not work for you, but if you come up with a better solution, I would love to hear it.
Currently i have this code in all my views which i don't want to go into landscape which is all except for one:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
return [self.selectedViewController supportedInterfaceOrientations];
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate
{
return YES;
}
this is the code in my tab bar controller:
-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
// You do not need this method if you are not supporting earlier iOS Versions
return [self.selectedViewController shouldAutorotateToInterfaceOrientation:interfaceOrientation];
}
-(NSUInteger)supportedInterfaceOrientations
{
if (self.selectedViewController)
return [self.selectedViewController supportedInterfaceOrientations];
return UIInterfaceOrientationMaskPortrait;
}
-(BOOL)shouldAutorotate
{
return YES;
}
And lastly the code in the viewcontroller that i want to go into landscape (because there is a video):
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return YES;
}
- (BOOL)shouldAutorotate
{
return YES;
}
- (NSInteger)supportedInterfaceOrientations
{
return UIInterfaceOrientationMaskAllButUpsideDown;
}
The views are all rotating like i want them to, the only problem is when the viewcontroller with the video in rotates and you then click on another view that view will stay in landscape, what i want to happen is this view to rotate straight into portrait without the user rotating the device into portrait. Anyone know what code i need?
This can be a difficult one to solve elegantly. Forcing orientation can be breaking Human Interface Rules rules or in the past just required calling private API's
I would recommend attempting a different approach which has worked for me in the past. When the user rotates the one viewcontroller that displays a video allow that to rotate but at that time remove any way the user can navigate away and then return those navigation controls when they rotate the device back to portrait. For me it was simply hiding the navigation bar until they returned to portrait. I like this because it is very clear to the user that they have to return the phone to portrait before moving on and they won't be surprised with navigating somewhere else that is magically another orientation.
Both on iPhone simulator and iPhone 3GS (iOS 6) I cannot manage to set the orientation to portrait upside down. I have just one ViewController. I've added this code in it:
-(BOOL) shouldAutorotate{
return YES;
}
-(UIInterfaceOrientation) preferredInterfaceOrientationForPresentation{
return UIInterfaceOrientationPortraitUpsideDown;
}
- (NSUInteger)supportedInterfaceOrientations{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
-(BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation{
if (toInterfaceOrientation==UIInterfaceOrientationPortrait || toInterfaceOrientation==UIInterfaceOrientationPortraitUpsideDown) {
return YES;
}
return NO;
}
I also added this to AppDelegate.m:
-(NSUInteger) application:(UIApplication *)application supportedInterfaceOrientationsForWindow:(UIWindow *)window{
return UIInterfaceOrientationPortrait | UIInterfaceOrientationPortraitUpsideDown;
}
I've also checked the plist file, both orientations are present there. On my storyboard, at Simulated Metrics Orientation is set to Inferred. I do nothing in my applicationDidFinishLaunchingWithOptions, except return YES. I've just added a UIImageView inside of this ViewController. Is it possible to make this orientation work?
supportedInterfaceOrientations returns an NSUInteger. It returns all of the interface orientations that the view controller supports, a mask of interface orientation values.
You need to return values defined in UIInterfaceOrientationMask Enum, like the following shows:
- (BOOL)shouldAutorotate {
return YES;
}
- (NSUInteger)supportedInterfaceOrientations {
return (UIInterfaceOrientationMaskPortrait | UIInterfaceOrientationMaskPortraitUpsideDown);
}
I know there's an answer that worked but for anyone else who's still stuck with the same issue:
I had a similar problem that was connected to Xcode: portrait rotations weren't being supported despite returning YES to - (BOOL) shouldAutorotateToInterfaceOrientation: for all cases. It turned out to be the enabled 'Supported Interface Orientations' in the summary window of my target's project editor:
The above 'iPhone/iPad Depoloyment Info' selections weren't doing it, it was the 'iPad Deployment Info' section that appears to control what the simulator will do despite the fact that I was only using the iPhone sim. Once I'd enabled the same orientations in that section then the iPhone simulation worked and I was able to test what happened when the simulator was rotated....
I tried many ways for this. It seems only one way it works, but globally through the app, not only for particular view controller.
First, you have to check on Upside Down of Device Orientation in target general settings.
Then, in navigation controller extension, you override the supportedInterfaceOrientations method
extension UINavigationController {
override public func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
return .All
}
}
I am currently working on a tabBar application. My tabBar controller is the rootViewController and I have 3 tabs. Each tab will have several UIWebView's on them which I would like to be able to support orientation once the webview has loaded. Once the webview has closed then orientation is no longer supported. How can I tell my other viewControllers to handle orientation instead of the rootViewController?
I hope I explained this to where it's clear.
As always TIA,
T
Ok this is a shot in the dark - This might not be what you are asking.
To support multiple orientations you need to do 2 things.
Check the orientation when the ViewController is first loaded.
Respond to orientation changed notifications / override orientation changed methods.
Here is how I do it:
- (BOOL) shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation
{
// Call my method to handle orientations
[self layoutViewsForOrientation:toInterfaceOrientation];
return YES;
}
- (void) viewWillAppear:(BOOL)animated
{
// ...
// Some code .....
// ...
// Call my method to handle orientations
[self layoutViewsForOrientation:self.interfaceOrientation];
}
- (void) layoutViewsForOrientation:(UIInterfaceOrientation) orientation
{
UIInterfaceOrientationIsLandscape(orientation) {
// Move views about if needed
} else {
// ....
}
}
I have a small application ipad, portrait mode is locked in the application,
The problem occurs when I turn down the IPAD, the display of the application is not running down
Can someone help me??
You should implement below method in all of your viewControllers.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
if(interfaceOrientation==UIInterfaceOrientationPortraitUpsideDown || interfaceOrientation==UIInterfaceOrientationPortrait)
{
return YES;
}
return NO;
}
Hope this help.