i have a problem with launchscreens. I create a storyboard with image. At designer it looks great, but on simulator happen something terrible, like this. I can't understand how it works. Can somebody explain it ? And one more question: how implement different images at storyboard or xib for different languages, if it is possible?
You need to do a few things.
First you need to tell the app in the Plist file that it will be landscape
Configure your launch screen storyboard with the image you want to show. If you want to show a different image based on the language then you need to localize the image.
In the AppDelegate override the method below to allow the app return to the "normal" orientation when it has finished launching:
public override UIInterfaceOrientationMask GetSupportedInterfaceOrientations(UIApplication application, UIWindow forWindow)
{
//select the option you need here
//if you only wants portrait use this: UIInterfaceOrientationMask.Portrait
return UIInterfaceOrientationMask.AllButUpsideDown;
}
This should works.
Related
I need to present a UIViewController (ViewControllerTwo) that only supports ".landscape" orientations from another UIViewController (ViewControllerOne) that only supports ".portrait" orientation. If you check the .gif below, you will notice that when the transition occurs it shrinks the content of "ViewControllerOne" and when you dismiss "ViewControllerTwo" the same happens.
The reason why this happens is related to the change of safe areas, which in portrait are different from landscape and vice versa. But if we override supportedInterfaceOrientations of "ViewControllerOne" to just support ".portrait" it should not be informed of the safe area changes if these changes relate to an unsupported orientation right?
Is this a bug/limitation from iOS?
(NO) -> What is the right way to handle this scenario?
(YES) -> What workaround do you recommend to solve this issue in the meantime?
You can check the Example Project here: https://github.com/mantuness/ExampleProject
Check the GIF below:
My universal app allows some view controllers to be in landscape, but not the first screen. The launch image looks like the first screen; it needs to be in portrait when running on iPhone. On iPad, all orientations are acceptable. How can this be handled?
override func supportedInterfaceOrientations() -> UIInterfaceOrientationMask {
can't be used for the View Controller for the launch storyboard. đŸ˜¿
Add "Initial interface orientation" key to your projects plist. Set the value to "Portrait (bottom home button)" or some other desired value. Go to the "General" tab of your project file and deselect the device orientations. In your view controllers override supportedInterfaceOrientations
This was a great start! Here's what else was needed… – Jessy
Initial interface orientation is the prettified name of the string key UIInterfaceOrientation. The Creating and Editing an Information Property List File documentation tells us that we would need an iPhone-specific entry, like this:
<key>UIInterfaceOrientation~iphone</key>
<string>UIInterfaceOrientationPortrait</string>,
Because that is the default, specifying it is not necessary. However, it is necessary to specify all four values for the Supported interface orientations (iPad) key, which is the prettified version of UISupportedInterfaceOrientations~ipad. UIInterfaceOrientation is ignored if the UISupportedInterfaceOrientations key is present, so the ~ipad part must be present.
in my app I allow the multitasking mode.
But I need to do some action if my view is too restricted.
Watching Apple documentation I saw this image
You can see that in iPad Pro in SplitView, both views are regular, instead in other iPads both views are compact.
I there something that allow me to know if my current view is regular or compact?
Thanks
This is my solution:
if (self.view.traitCollection.horizontalSizeClass == UIUserInterfaceSizeClassRegular){
NSLog(#"REGULAR HORIZONTAL");
return TRUE;
}else{
NSLog(#"COMPACT HORIZONTAL");
return FALSE;
}
If you need to handle it programatically, you can override -traitCollectionDidChange: and look at the self.traitCollection property on that view and make changes depending on the output.
However -viewWillTransitionToSize:withTransitionCoordinator: will get you a more fine grained response to how big the view controller has been resized to.
I am working on an iPad/iPhone tab-bar based application. I have about 30 class files and need to enable rotation in the app, so that iPad users can view at any orientation. As far as I know, every class needs rotation to be enabled by using the following:
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Return YES for supported orientations.
return YES;
}
However, I have some UIViewControllers created and displayed completely in a single class file, and as far as I know you cannot enable it for that type.
Is there a way I can enable global rotation for the app? I have tried in Info.plist. is there something that can be added to the AppDelegate to enable global rotation?
Btw: I have already tried adding returning YES for rotation in every class file.
Thanks in advance,
Baharini
In Xcode on the Project Navigator click on the project name. Now on center view on the Summary tab, you can see the iPad\iPhone Development Info in this part there is Supported Device Orientations. You can set all of them for supporting any orientation!
I hope it be useful for you!
I'm pretty new to MonoTouch and I'm having problems getting my app to rotate from portrait to landscape mode.
My project has two XIB files, the MainWindow added by MonoTouch and MainController.xib which I have added. The MainController has a single label and no other controls. In my Main.cs I have the following to load the MainController.xib file:
UIViewController controller = new MainController();
window.AddSubview(controller.View);
In the MainController code I added
public override bool ShouldAutorotateToInterfaceOrientation (UIInterfaceOrientation toInterfaceOrientation)
{
return false;
}
It all runs fine and the label displays but when I rotate the simulator nothing rotates. I'm sure it's something really simple that I'm getting wrong but I just can't seem to crack it.
Any help would be appreciated.
You can look at TweetStation for a sample.
In this particular case, you might want to return "true" instead of false in the sample above.