big*_*ato 1 storyboard ios swift
我正在尝试设置应用程序的启动屏幕和初始视图。但是,我也无法露面。
我有这样的设置:
我错过了一步吗?我是否应该在启动屏幕上看到带有“ 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()
}
}
Run Code Online (Sandbox Code Playgroud)
还有我的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.
}
*/
}
Run Code Online (Sandbox Code Playgroud)
很抱歉出现菜鸟问题。
==更新==
构建它时,我确实收到以下2条警告:
file:///Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:警告:不支持的配置:由于缺少入口点,无法访问场景,并且没有通过-instantiateViewControllerWithIdentifier:进行运行时访问的标识符。
/Users/emai/Documents/ios/Sherpa/SherpaNewYork/LaunchScreen.storyboard:9:由于缺少入口点,无法访问场景,并且没有通过-instantiateViewControllerWithIdentifier:进行运行时访问的标识符。
我还为启动屏幕演示图板未显示而苦苦挣扎。我尝试了所有无法找到的修复方法。然后我清除了模拟器上的缓存,它开始工作了!原来这是一个模拟器问题。我在终端中使用以下命令清除了缓存:xcrun simctl
| 归档时间: |
|
| 查看次数: |
3791 次 |
| 最近记录: |