Terminating app due to uncaught exception ' uiapplicationinvalidinterfaceorientation ', Reason: ' S

Source: Internet
Author: User

The title error is displayed when calling Uiimagepickercontroller to display the picture library.


Later found on the forum there is a solution to this problem, recorded as follows:


1. Adding this method to the appdelegate is OK.


#if __iphone_os_version_max_allowed >= __iphone_6_0

-(Nsuinteger) Application: (UIApplication *) application Supportedinterfaceorientationsforwindow: (UIWindow *) window
{
return uiinterfaceorientationmaskall;
}

#endif


If the program is not only support horizontal screen, but horizontal screen vertical screen is supported, then to 1 can be solved. However, if the program only supports horizontal screens, this workaround causes a problem:

All the interface can support the vertical screen, this is not what we want, then we need to add the following steps.


2. From

Uinavigationcontroller

Derive one of your own class Myrootviewcontroller:

There are several ways to add a class:

-(Nsuinteger) supportedinterfaceorientations

{

Returnuiinterfaceorientationmasklandscape;

}


-(BOOL) shouldautorotate {

return YES;

}



Override to allow orientations other than the default portrait orientation.

-(BOOL) Shouldautorotatetointerfaceorientation: (uiinterfaceorientation) interfaceorientation

{

Return YES for supported orientations

return (interfaceorientation = = Uideviceorientationlandscapeleft | |

Interfaceorientation = = uideviceorientationlandscaperight);

}

3. In the Laugth method for finding Appdelegate, replace with:

Create a Navigation Controller with the Director

Navcontroller_ = [[Myrootviewcontrolleralloc] initwithrootviewcontroller:director_];

Navcontroller_.navigationbarhidden =yes;

In the. h file, change the definition of Navcontroller_ to Myrootviewcontroller


4. This is the perfect solution. Thanks for the internet, thanks to Google.


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.