当我尝试加载此视图时,屏幕几乎黑屏。但是,如果我添加 view.backgroundColor = .red ,它将正确显示红色。只是我在情节提要中所做的设置不会显示。
这是我使用的代码:
import UIKit
class SceneDelegate: UIResponder, UIWindowSceneDelegate {
var window: UIWindow?
func scene(_ scene: UIScene, willConnectTo session: UISceneSession, options connectionOptions: UIScene.ConnectionOptions) {
guard let _ = (scene as? UIWindowScene) else { return }
guard let windowScene = scene as? UIWindowScene else { return }
window = UIWindow(windowScene: windowScene)
let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
window?.rootViewController = mainStoryboard.instantiateViewController(withIdentifier: "ResultsViewController") as! ResultsViewController
window?.makeKeyAndVisible()
}
import UIKit
class ResultsViewController: UINavigationController {
override func viewDidLoad() {
super.viewDidLoad()
view.backgroundColor = .blue
}
}
答案 0 :(得分:1)
您似乎已在情节提要中创建了diff_y[y_actual[:,]> 0 and y_predicted[:,0] <0] *=2
。您必须从情节提要中加载它,才能将其设置为ResultsViewController
。
rootViewController
注意:不要忘记在情节提要中将let mainStoryboard = UIStoryboard(name: "Main", bundle: nil)
window?.rootViewController = mainStoryboard.instantiateViewController(withIdentifier: "ResultsViewController") as! ResultsViewController
的标识符设置为“ ResultsViewController”。