Application tried to present a nil modal view controller in target "Current View Controller" solution

Source: Internet
Author: User

Scene reproduction

1, customize a storyboard:

Open Xcode, press Cmd+n, create a new storyboard--->next

Name the newly created storyboard: Testviewcontroller--->create

Add a label to the Testviewcontroller.storyboard whose text is: Hello-ios

2, write the UIButton uicontroleventtouchupinside event:

-(Ibaction) Btnclick: (ID) sender {    // Create load Storyboard    Uistoryboard * Storyboard = [Uistoryboard storyboardwithname:@ "testviewcontroller"  Bundle:nil];     // Associate Controller to storyboard     _viewofstoryboard = [Storyboard Instantiateinitialviewcontroller];     = [Uicolor whitecolor];    [Self Dismissviewcontrolleranimated:yes completion:nil];    [Self Presentviewcontroller:_viewofstoryboard animated:yes completion:nil];}

The following operations are run:

The following problems were encountered in loading the custom storyboard interface

Error reason: The application view presents an empty mode view controller to the target, which simply says that the view controller in storyboard is empty.

3. Solution:

    • The relevant answers are given on the StackOverflow (The following is a personal translation, as indicated by the error)

Check The identifier of the Viewcontroller, if it is the same, then mentioned in storyboard.

    • Check the identifier on the Viewcontroller to make sure it is unique on the storyboard.

Make sure this your buddiesorfacebook is not nil. Set a breakpoint on this line and on the debug area at the bottom see whether the object was not nil. If It is nil then problem lies in the storyboard connection.

    • Make sure that your buddies or Facebook (which is not understood) is not empty. You can set breakpoints for debugging, and if the object is empty, then there is a problem with the storyboard connection.

If your current viewcontroller are not launched from storyboard then get Storyboard object like this:

If the current Viewcontroller does not start loading, you can refer to the following standard notation:

Uistoryboard *storyboard = [Uistoryboard storyboardwithname:@ "mainstoryboard"* Buddiesorfacebook = [Storyboard   instantiateviewcontrollerwithidentifier:@ "buddiesfbfriends " ] ; [Self Presentviewcontroller:buddiesorfacebook animated:yes completion:nil];

The solution above did not solve my problem, so I took a second set of solutions.

To open the Testviewcontroller.storyboard view, proceed as follows:

Check the is Initial View Controller to ensure that Viewcontroller is initialized.

4, Results:

Last run correctly, such as:

Application tried to present a nil modal view controller on target ' Current View controller ' solution

Related Article

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.