Ios eProject navigator菜单中的主脚本 然后在Info.plist中删除行主情节提要文件基名称 不要忘记删除项目目标中的-常规部署信息中的单元格-主界面(只需删除主界面即可)

Ios eProject navigator菜单中的主脚本 然后在Info.plist中删除行主情节提要文件基名称 不要忘记删除项目目标中的-常规部署信息中的单元格-主界面(只需删除主界面即可),ios,xcode,storyboard,xcode6,Ios,Xcode,Storyboard,Xcode6,之后,进入AppDelegate.swift,在函数中完成启动操作,使用选项编写下一步: func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { // Override point for customization after application lau

之后,进入AppDelegate.swift,在函数中完成启动操作,使用选项编写下一步:

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    // Override point for customization after application launch.

    window = UIWindow(frame: UIScreen.main.bounds)
    window?.makeKeyAndVisible()
    window?.rootViewController = UINavigationController(rootViewController: ViewController())

    return true
}
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
    guard let windowScene = (scene as? UIWindowScene) else { return }

    window = UIWindow(frame: windowScene.coordinateSpace.bounds)
    window?.windowScene = windowScene
    window?.rootViewController = ViewController()
    window?.makeKeyAndVisible()
}
Xcode 11.2.1Swift 5

  • 首先,您需要在项目导航器菜单中删除Main.storyboard
  • 然后在Info.plist中删除行主情节提要文件基名称
  • 不要忘记删除项目目标-常规-部署信息中的单元格主界面(只需删除Main
  • 这一步很重要,以前的Xcode和Swift版本中没有这一步。在Info.plist中转到:应用程序场景清单场景配置应用程序会话角色第0项并在此处删除故事板。名称
  • 在完成这些步骤后,转到SceneDelegate,并在函数场景中编写下一步:

    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
    
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()
        window?.rootViewController = UINavigationController(rootViewController: ViewController())
    
        return true
    }
    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let windowScene = (scene as? UIWindowScene) else { return }
    
        window = UIWindow(frame: windowScene.coordinateSpace.bounds)
        window?.windowScene = windowScene
        window?.rootViewController = ViewController()
        window?.makeKeyAndVisible()
    }
    

  • 更新:Swift 5和iOS 13:

  • 创建一个单视图应用程序
  • 删除Main.storyboard(右键单击并删除)
  • 从Info.plist文件中的默认场景配置中删除“情节提要名称”:
  • 打开
    SceneDelegate.swift
    并从以下位置更改
    func场景
  • func场景(场景:UIScene,willConnectTo会话:UISceneSession,选项connectionOptions:UIScene.connectionOptions){
    //使用此方法可以选择性地配置UIWindow`window`并将其附加到提供的UIWindowScene`scene`。
    //如果使用情节提要,“窗口”属性将自动初始化并附加到场景。
    //此委托并不意味着连接的场景或会话是新的(请参见'application:ConfigurationForConnectionSceneSession'。
    guard let=(场景为?UIWindowScene)else{return}
    }
    

    func场景(场景:UIScene,willConnectTo会话:UISceneSession,选项connectionOptions:UIScene.connectionOptions){
    //使用此方法可以选择性地配置UIWindow`window`并将其附加到提供的UIWindowScene`scene`。
    //如果使用情节提要,“窗口”属性将自动初始化并附加到场景。
    //此委托并不意味着连接的场景或会话是新的(请参见'application:ConfigurationForConnectionSceneSession'
    如果让windowScene=场景为?UIWindowScene{
    let window=UIWindow(windowScene:windowScene)
    window.rootViewController=ViewController()
    self.window=window
    window.makeKeyAndVisible()的
    }
    }
    
    在Xcode 11和ios 13上更新。在您设置了所有内容但仍然看到黑屏后,这是因为生命周期由UISceneDelegate处理,并且当您创建新项目时,它将自动生成UISceneDelegate.m和UISceneDelegate.h。在我们习惯UISceneDelegate之前回到过去。以下步骤可能会有所帮助:

  • 删除plist中的应用程序场景清单

  • 删除应用程序场景清单.h和应用程序场景清单.m

  • 在APPdelegate.m中删除#pragma标记-UISceneSession生命周期下的代码

  • 添加@property(强,非原子)UIWindow*窗口;在APPdelegate.h中


  • ,这是一个非常好的教程阅读此:iOS9和Xcode 7的最新教程:存在边界问题,UIScreen.mainScreen()。边界正在打印:(0.0,0.0320.0480.0)。为什么?我喜欢保留
    LaunchScreen.xib
    和相应的
    Info.plist
    条目。没有它,这个应用程序就不会占据更大的iPhone的整个屏幕,这很难看。我喜欢自己保留故事板。创建各种内容很方便,但我需要在不依赖情节提要的情况下进行初始设置。可能是Xcode 7中的错误,我根本无法从项目信息设置屏幕中删除Main.storyboard。我使用了@Silentwarrior提到的Xcode 5空应用程序模板。除非手动安装根ViewController,否则此答案会在Xcode 7中生成运行时错误:“NSInternalInconsistencyException”,原因:“应用程序窗口应在应用程序启动结束时具有根视图控制器”请同时添加以下代码:self.window.rootViewController=[[ViewController alloc]init];在AppDelegate.m中,使用didFinishLaunchingWithOptions方法。否则您将得到以下错误:“应用程序窗口在应用程序启动结束时应该有一个根视图控制器”谢谢。请注意,您需要在Xcode更新后替换此模板。如果您将其放入~/Library/Developer/Xcode/Templates/Project Templates/iOS/Application/中,则不必每次Xcode更新时都替换它updates@harrisg在约塞米蒂找不到此目录。你能证实它的存在吗?感谢此方法适用于Xcode 7.1,但是创建的LaunchScreen.storyboard可能不是某些人想要的。我最终使用了它,因为它不会干扰我手动创建的视图。请记住将文件解压缩到目录中,复制是不够的。如果我只是删除情节提要文件而没有手动从中删除相应的引用,则使用Xcode 9.1和Swift 4。plist会出现错误“无法在捆绑包中找到名为“Main”的情节提要”。似乎我必须手动删除引用。您还必须从Info.plist中删除“主故事板文件基名称”,否则会出现错误
    #import <Availability.h>
    
    #ifndef __IPHONE_3_0
    #warning "This project uses features only available in iOS SDK 3.0 and later."
    #endif
    
    #ifdef __OBJC__
    #import <UIKit/UIKit.h>
    #import <Foundation/Foundation.h>
    #endif
    
    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    //Override point for customization after application launch.
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    return YES;
    
    //AppDelegate.h
    
    
    @property (strong, nonatomic) UIViewController *viewController;
    @property (strong, nonatomic) UINavigationController *nav;
    
    //AppDelegate.m
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {`enter code here`
        // Override point for customization after application launch.
    
        CGRect screenBounds = [[UIScreen mainScreen] bounds];
    
        UIWindow *window = [[UIWindow alloc] initWithFrame:screenBounds];
    
    
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    
    
    
        self.viewController = [[UIViewController alloc] initWithNibName:@"ViewController" bundle:nil];
    
        self.nav = [[UINavigationController alloc] initWithRootViewController:self.viewController];
    
        [window setRootViewController:  self.nav];
    
        [window makeKeyAndVisible];
    
        [self setWindow:window];
    
        return YES;
    }
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        // Override point for customization after application launch.
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        MyViewController *viewController = [[MyViewController alloc] initWithNibName:@"MyViewController" bundle:nil];
        self.window.rootViewController = viewController;
        [self.window makeKeyAndVisible];
        return YES;
    }
    
        let initialViewController = UIViewController()
        initialViewController.view.backgroundColor = .white
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.rootViewController = initialViewController
        window?.makeKeyAndVisible()
    
    func application(_ application: UIApplication,
                     didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
    
        let window = UIWindow(frame: UIScreen.main.bounds)
        window.backgroundColor = .white
        window.rootViewController = MyRootViewController()
        window.makeKeyAndVisible()
        self.window = window
    
        return true
    }
    
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
        // Override point for customization after application launch.
    
        window = UIWindow(frame: UIScreen.main.bounds)
        window?.makeKeyAndVisible()
        window?.rootViewController = UINavigationController(rootViewController: ViewController())
    
        return true
    }
    
    func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
        // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
        // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
        // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
        guard let windowScene = (scene as? UIWindowScene) else { return }
    
        window = UIWindow(frame: windowScene.coordinateSpace.bounds)
        window?.windowScene = windowScene
        window?.rootViewController = ViewController()
        window?.makeKeyAndVisible()
    }