我正在尝试设置我的应用程序的启动屏幕和初始视图。然而,我无法让任何一个显示出来。
我已经设置了如下内容:
我是否漏掉了一步?我不应该看到一个带有“blah”的页面作为启动屏幕吗?相反,当我运行模拟器时,它只是黑色的。
另外,我也不明白为什么我的初始视图也没有显示出来。
在我的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()
}
}
我的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.
}
*/
}
抱歉,这些问题有点初学者的问题。
== 更新 ==
构建时我确实收到了这两个警告:
file:///Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard: 警告:不支持的配置:由于缺少入口点而无法访问场景,并且没有标识符可通过-instantiateViewControllerWithIdentifier:进行运行时访问。
/Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:9:由于缺少入口点而无法访问场景,并且没有标识符可通过-instantiateViewControllerWithIdentifier:进行运行时访问。