简体   繁体   中英

Adding Storyboard support in existing project

I am using this GitHub project for an application that I am working on ( Github Link 1 ). Unfortunately, this project doesn't support Storyboards. However, I did find one version with Storyboard support ( Github Link 2 ) however, I was unable to get it to work with the suggestions that they made. Here are the results of the suggestions:

  • Subclass RESideMenu as RootSideMenuViewController do and set the initial scene's custom class as the one you created.

When I tried this:

 RESideMenuItem *homeItem = [[RESideMenuItem alloc] initWithTitle:@"Home" action:^(RESideMenu *menu, RESideMenuItem *item) { [menu hide]; UIViewController* vc = [self.storyboard instantiateViewControllerWithIdentifier:@"MainViewController"]; [menu displayContentController:vc]; }]; 

When I tried it, I received an error saying:

Property 'storyboard' not found on object of type 'AppDelegate *'
  • Use Storyboard Id to instantiate a view controller. ( UIStoryboard – instantiateViewControllerWithIdentifier: )

Here is the code when I attempted to try it:

 RESideMenuItem *homeItem = [[RESideMenuItem alloc] initWithTitle:@"Home" action:^(RESideMenu *menu, RESideMenuItem *item) { [menu hide]; UIViewController* vc = [UIStoryboard instantiateViewControllerWithIdentifier:@"MainViewController"]; [menu displayContentController:vc]; }]; 

When I tried this, I got an error message, saying:

No known class method for selector 'instantiateViewControllerWithIdentifier:'

The last one, I realized that it is already been done.

I have looked around Google to see if I could find anything, and found this:

UIStoryboard [instantiateViewControllerWithIdentifier:@"MainViewController"];

This didn't work either.

Sorry for the long post, but I'm not too sure what else I can do to fix this. Are there any other solutions? Did I overlook something? Please ask if I am not being clear on something.

For reference, I'm using Xcode 4.6.3. I am using Storyboards, and I am coding my project using ARC.

You need to load the storyboard first:

[[UIStoryboard storyboardWithName:@"MainStoryboardName" bundle: nil] instantiateViewControllerWithIdentifier:@"SomeVCInMainStoryboard"];

Assuming that project is setup correctly, you should just need to change the names to load the Storyboard and a subsequent view controller.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM