简体   繁体   English

Xcode:LaunchScreen.storyboard 没有出现

[英]Xcode: LaunchScreen.storyboard is not showing up

I'm trying to set up the launch screen and initial view of my app.我正在尝试设置我的应用程序的启动屏幕和初始视图。 However, I can't get either to show up.但是,我不能让他们出现。

I have this set up:我有这个设置:

在此处输入图片说明

在此处输入图片说明

Am I missing a step?我错过了一步吗? Shouldn't I be seeing a page with "blah" on it as the launch screen?我不应该看到一个带有“blah”的页面作为启动屏幕吗? Instead, when I run the simulator it's just black.相反,当我运行模拟器时它只是黑色的。

Also, I don't understand why my initial view isn't showing up either.另外,我不明白为什么我的初始视图也没有出现。

In my AppDelegate.swift file:在我的 AppDelegate.swift 文件中:

import UIKit

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

  var window: UIWindow?

  func application(application: UIApplication,
      didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        self.window?.rootViewController = self.rootViewController()
    return true
  }

  private func rootViewController() -> UIViewController {
    return MapViewController.init()
  }

}

And my MapViewController.swift:还有我的 MapViewController.swift:

import UIKit

class MapViewController: UIViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
        var label = UILabel(frame: CGRectMake(0, 0, 200, 21))
        label.center = CGPointMake(160, 284)
        label.textAlignment = NSTextAlignment.Center
        label.text = "I am a test label"
        self.view.addSubview(label)
        NSLog("heyyyy!!") // <----------------- doesn't get printed either, so I think I'm missing something again...
    }

    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
        // Dispose of any resources that can be recreated.
    }


    /*
    // MARK: - Navigation

    // In a storyboard-based application, you will often want to do a little preparation before navigation
    override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {
        // Get the new view controller using segue.destinationViewController.
        // Pass the selected object to the new view controller.
    }
    */

}

Sorry for the noob questions.对不起,菜鸟问题。

== UPDATE == == 更新 ==

I do get these 2 warnings when I build it:当我构建它时,我确实收到了这两个警告:

file:///Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard: warning: Unsupported Configuration: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:. file:///Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:警告:不支持的配置:由于缺少入口点,场景无法访问,并且没有通过 -instantiateViewControllerWithIdentifier: 进行运行时访问的标识符。

/Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:9: Scene is unreachable due to lack of entry points and does not have an identifier for runtime access via -instantiateViewControllerWithIdentifier:. /Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:9:由于缺少入口点,场景无法访问,并且没有通过 -instantiateViewControllerWithIdentifier: 进行运行时访问的标识符。

I also struggled with a launchscreen storyboard not showing up.我也为没有出现的启动屏幕故事板而苦苦挣扎。 I tried everything fix I could find to no avail.我尝试了所有我能找到的修复方法都无济于事。 Then I cleared the cache on my Simulator and it worked!然后我清除了模拟器上的缓存并且它工作了! Turned out it was a simulator problem.原来是模拟器问题。 I cleared the cache with this command in terminal: xcrun simctl erase all我在终端中使用此命令清除了缓存:xcrun simctl erase all

It looks like you haven't set up your storyboards with an entry point.看起来您还没有使用入口点设置故事板。 Set up the first scene you want to show as the Initial View Controller设置要显示为Initial View Controller的第一个场景

在此处输入图片说明

sure, this answer is a little late.当然,这个答案有点晚了。 ;-) Had the some problem but i fortuitous found a quiet simple solution using the Launch Screen.storyboard created with the app automatic. ;-) 有一些问题,但我偶然发现了一个安静的简单解决方案,使用应用程序自动创建的 Launch Screen.storyboard。

Open the App-Settings and there App Icons and Launch Images打开应用程序设置和应用程序图标并启动图像

在此处输入图片说明

Select Launch Screen.storyboard in the DropDown-List, even when u think, this is already selected.在下拉列表中选择Launch Screen.storyboard ,即使您认为它已经被选中。 The display of the screen won´t change after selecting.选择后屏幕显示不会改变。 But when restart the project, the Launch Screen was showed!但是当重新启动项目时,显示了启动屏幕!

BTW to test this tidy, u can set a breakpont in the last line of func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)顺便说一句,为了测试这个整洁,你可以在func 应用程序的最后一行设置一个断点(应用程序:UIApplication,didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?)

had the same problem with the launchscreen.启动屏幕也有同样的问题。 As mentioned from Abizern, there is no ViewController allowed.正如 Abilern 所提到的,不允许使用 ViewController。 If you had one only deleting this one will not be enough some times.如果你有一个只删除这个有时是不够的。 The LaunchScreen file could still have some connections to the ViewController which is not available any more. LaunchScreen 文件可能仍然与不再可用的 ViewController 有一些连接。 This is a problem, too.这也是一个问题。

My fix:我的修复:

  1. Delete ViewController for LaunchScreen删除 LaunchScreen 的 ViewController
  2. Removed connections in LaunchScreen.storyboard删除 LaunchScreen.storyboard 中的连接
  3. Removed app from Device从设备中删除了应用程序
  4. Reinstall重新安装

-> Worked :) - >工作:)

What you are missing is that a launch screen is static!您缺少的是启动屏幕是静态的! It does not need a controller or anything.它不需要控制器或任何东西。 A controller will not do anything.控制器不会做任何事情。 For the launch screen you can design the UI only using the interface builder, not via code.对于启动屏幕,您只能使用界面构建器来设计 UI,而不是通过代码。

Xcode should generally tell you that, if you try to set a custom controller on the launch screen view it results in an error. Xcode 通常应该告诉您,如果您尝试在启动屏幕视图上设置自定义控制器,则会导致错误。

So deleting the LaunchScreen.storyboard + LaunchScreenViewController.swift files and adding a Launch Screen.xib file worked in fixing the launch screen.所以删除 LaunchScreen.storyboard + LaunchScreenViewController.swift 文件并添加 Launch Screen.xib 文件可以修复启动屏幕。 This makes sense to me since the launch screen should be static and not use code.这对我来说很有意义,因为启动屏幕应该是静态的并且不使用代码。

However the view is still black after the launch screen.但是在启动屏幕后视图仍然是黑色的。 I'll make another SO question for that.我会为此提出另一个问题。

i know it is very late but i want to share how i fixed it, if you are checking on real device then try to delete the app first, restart the handset and then reinstall the app.我知道现在已经很晚了,但我想分享我是如何修复它的,如果您在真实设备上检查,则尝试先删除该应用程序,重新启动手机,然后重新安装该应用程序。 it will be fixed if you have followed all steps like clearing cache and settings in Target - General Tab etc.如果您已按照所有步骤(例如清除目标 - 常规选项卡等中的缓存和设置)进行操作,它将被修复。

In my case, the project navigator file filter was set to "recent".就我而言,项目导航器文件过滤器设置为“最近”。 See bottom left of Xcode.请参阅 Xcode 的左下角。 I unselected recent, and the file showed up.我最近取消选择,文件出现了。

After trying every other answer here, I finally deleted the LaunchScreen.Storyboard file and created a new one.在尝试了所有其他答案之后,我终于删除了 LaunchScreen.Storyboard 文件并创建了一个新文件。 This was the only thing that fixed the issue for me.这是唯一为我解决问题的方法。

Easiest solution is to uninstall and reinstall the app when testing in the simulator.最简单的解决方案是在模拟器中测试时卸载并重新安装应用程序。 No need to remove and re-create LaunchScreen.Storyboard .无需删除并重新创建LaunchScreen.Storyboard

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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