user3418565
user3418565

Reputation: 1

How to remove storyboard from existing iPhone project

I am new to iPhone programming and now facing problem with storyboard. I want to remove storyboard from application and call view controller from appDelegate programmatically. How can I accomplish this?

Here is my code in appDelegate :

FirstViewController *firstView = [[FirstViewController alloc] init];
self.window.rootViewController = signInView;
return YES;

Still its showing black screen. Please help me. Thanks.

Upvotes: 0

Views: 1111

Answers (8)

user2366948
user2366948

Reputation:

Delete MainStoryBorad file from your project.

Delete MainStroryBoard Key from info.plist file.

Clear MainInterface option from Project setttings.

Create New UIViewController with XIB file named "MyViewController"

In your AppDelegate.h add @property for New Controller "MyViewController"

In your AppDelegate.m update didFinishLaunchingWithOptions method this way.

-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;

     MyViewController *viewController = [[MyViewController alloc]     initWithNibName:@"MyViewController" bundle:nil];
     UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:viewController];
     self.window.rootViewController = nav;

     [self.window makeKeyAndVisible];

     return YES;
}

Upvotes: 0

Sunil
Sunil

Reputation: 107

Please find the below link and Check with things.. 1. Info.plist or General Info -> Removing main Interface 2. Check with .xib connections -> Custom class is added, view connection in .xib

https://github.com/sunilhts/RemoveDefaultStoryBoard

Upvotes: 0

Alex Andrews
Alex Andrews

Reputation: 1498

I think it is better to use storyboards than xib if your application is not that much complicated with large number of UI View Controllers. If you want to remove storyboard from project and use nib to use with the development do the steps with this link:

http://www.wastedpotential.com/create-an-ios-app-without-storyboards-in-xcode-5/

Upvotes: 0

swiftBoy
swiftBoy

Reputation: 35783

Here are the steps how I am doing.

  1. Create a Empty project or If you have already created no worries, just remove StoryBoard entry from plist as @trick suggested.

  2. delete MainStoryBorad file from your project

  3. Create New UIViewController with XIB file named "MyViewController"

  4. In your AppDelegate.h add @property for New Controller "MyViewController"

  5. In your AppDelegate.m update didFinishLaunchingWithOptions method this way.


-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:
(NSDictionary *)launchOptions
{
            self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;

             MyViewController *viewController = [[MyViewController alloc]     initWithNibName:@"MyViewController" bundle:nil];
             UINavigationController *nav = [[UINavigationController alloc]  initWithRootViewController:viewController];
             self.window.rootViewController = nav;

             [self.window makeKeyAndVisible];

             return YES;
        }

Upvotes: 0

Scimmia Alpha
Scimmia Alpha

Reputation: 211

Maybe you have to remove the Main Interface in your project settings.

Upvotes: 0

dasdom
dasdom

Reputation: 14063

Did you initialize the window and made it key?

Here is an implementation of one of my apps:

self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = [[DDHDemoViewController alloc] init];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;

Upvotes: 0

Ryan
Ryan

Reputation: 4884

remove Main storyboard file base name. It's .plist.

enter image description here

Upvotes: 1

michaelsnowden
michaelsnowden

Reputation: 6192

The reason it's showing a black screen is because there is nothing configured in your FirstViewController class. Try setting firstView.view.backgroundColor = [UIColor greenColor]; right before the return YES' and you'll see that the FirstViewController is in fact loading; it just doesn't have any configuration besides what you've done in the init method of your FirstViewController class.

Honestly, configuring ViewControllers outside of the storyboard is not fun for beginners. I don't know why you want to do it, but your alternatives are using .nibs or adding everything manually. I encourage you not to delete your storyboard, but if you must, your code is fine. Just delete the storyboard file, or better yet, just don't use it until you decide to come back to it because it's a better idea.

Upvotes: 0

Related Questions