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
and LaunchScreen.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 in
Info.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;
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…