Xcode without Storyboard and ARC
Create a project with an Empty application and Add any viewcontroller (i added TestViewController here)
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions: (NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
STEPS FOR REMOVE ARC
1) In build setting set Automatic Reference Counting to NO.
///////////////////////////////////////////////////////////////////////////END///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
If you have Already Created Application with storyboard and ARC then
STEPS FOR REMOVE STORY BOARD
1) Remove Main.storyboard file from your project.
2) Add new files with xib for your controller , if it is not added in compiled sources in build phases then add there manually.
3) Remove Main storyboard file base name from plist.
4) Change appdelegate didFinishLaunchingWithOptions file and add :
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
[self.window makeKeyAndVisible];
just like :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
Now,in above example you have to manage memory management manually like ,
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] autorelease];
[test release];
STEPS FOR REMOVE ARC
1) In build setting set Automatic Reference Counting to NO.
Create Project Without Storyboard
Create a Empty application from the template .And then Add a ViewController to Project by right-click and add new file then choose and choose cocoa touch in left pane .
Then select the First option Objective-C Class and then give name for the class .
Choose UIViewController from subclasss .
Make sure checkbox with option ' With XIB or user interface ' is checked and then click next .
project without a storyboard is created in XCode 5
If you would like to navigation controller it can be achieved like the below code
Appdelegate.h
#import
@class InitialViewController;
@interface SampleAppDelegate : UIResponder
@property (strong, nonatomic) UIWindow *window;
@property (strong, nonatomic) InitialViewController *viewController;
@end
Appdelegate.m
#import "SampleAppDelegate.h"
#import "InitialViewController.h"
@implementation SampleAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[InitialViewController alloc]initWithNibName:@"InitialViewController" bundle:nil];
UINavigationController *navi = [[UINavigationController alloc]initWithRootViewController:self.viewController];
self.window.rootViewController = navi;
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
Xcode 5 - iOS - How to Create a View Controller in Xcode without Storyboard or XIB and how to configure it into AppDelegate as the root view
In AppDelegate.m
:
CustomViewController *rootViewController = [CustomViewController new];
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
self.window.rootViewController = rootViewController;
[self.window makeKeyAndVisible];
In CustomViewController.m
override:
- (void)loadView {
//Configure your view
self.view = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
//other stuff
[self.view setBackgroundColor:[UIColor redColor]];
UIButton *button = /* alloc init etc. */
[self.view addSubview:button];
}
Xcode 6 without Storyboard
put Default-568h@2x to your app bundle with dimension 1136x568. You can assign launch images using xcode catalog assets alternatively.
How to create an Empty Application in Xcode without Storyboard
There is no option in XCode6
and above versions for directly creating an Empty Application as in XCode5
and earlier. But still we can create an application without Storyboard
by following these steps:
- Create a
Single View Application
. - Remove
Main.storyboard
andLaunchScreen.xib
(select them, right-click, and choose to either
remove them from the project, or delete them completely). - Remove "Main storyboard file base name" and "Launch screen interface
file base name" entries inInfo.plist
file. - Open AppDelegate.m, and edit applicationDidFinishLaunchingWithOptions so that it looks like this:
Swift 3 and above:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool
{
self.window = UIWindow(frame: UIScreen.main.bounds)
self.window?.backgroundColor = UIColor.white
self.window?.makeKeyAndVisible()
return true
}
Swift 2.x:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool
{
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
self.window?.backgroundColor = UIColor.whiteColor()
self.window?.makeKeyAndVisible()
return true
}
Objective-C:
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.window.rootViewController = [[ViewController alloc] init];
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
return YES;
}
xcode 5 - open a project without story board
STEPS FOR REMOVE STORY BOARD
1) Remove Main.storyboard file from your project.
2) Add new files with xib for your controller , if it is not added in compiled sources in build phases then add there manually.
3) Remove Main storyboard file base name from plist.
4) Change appdelegate didFinishLaunchingWithOptions file and add :
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
[self.window makeKeyAndVisible];
just like :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]] ;
// Override point for customization after application launch.
TestViewController *test = [[TestViewController alloc] initWithNibName:@"TestViewController" bundle:nil];
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:test];
self.window.rootViewController = nav;
[self.window makeKeyAndVisible];
return YES;
}
When I create a new project in xcode 11 it goes without storyboard and if I run old project it comes without controllers?
Select User Interface as Storyboard while creating a new project in Xcode 11.
Related Topics
Dyld'_Abort_With_Payload: Without an Error Message
Changing Vc Issue in Swift. How to Pass Data Between Views in Tab Bar Controller
Swift Programmatically Navigate to Another View Controller/Scene
Linker Command Failed with Exit Code 1 (Use -V to See Invocation), Xcode 8, Swift 3
Xcode Quits Unexpectedly Every Time I Open My Project
Uitableview - Change Section Header Color
Delete All Keys from a Nsuserdefaults Dictionary iOS
Force Landscape Orientation in Uiimagepickercontroller
Framework Not Found Googletoolboxformac
Update Restkit 'Lcl_Rk.H' File Not Found in Rklog.H
iOS 8 - Can't Install Enterprise App
How to Set Cg_Context_Show_Backtrace Environmental Variable
How to Set the Title of a Uibutton as Left-Aligned