我需要根据是否启用画外音来更改初始视图控制器。我已经尝试了多种方法,但是总是收到相同的错误:“类型'AppDelegate'的值没有成员'window'” 这就是我的didFinishLaunchingWithOptions中的内容。
print("voiceover: \(voiceOver)") // prints if voice over is on
self.window = UIWindow(frame: UIScreen.mainScreen().bounds)
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let initialViewController = storyboard.instantiateViewController(withIdentifier: "voiceoverViewController")
self.window?.rootViewController = initialViewController
self.window?.makeKeyAndVisible()
“ AppDelegate”类型的值没有成员“窗口”
答案 0 :(得分:2)
您必须手动声明Route::get('{model}', 'CrudController@index')->name('{model}.index');
属性:
window
var window: UIWindow?
只是一个协议,它没有为您声明任何属性。
答案 1 :(得分:0)
您不必手动声明窗口变量
它在您项目的 SceneDelegate 文件中可用
它将具有预定义的方法:
func scene(_ scene:UIScene,willConnectTo会话:UISceneSession, 选项connectionOptions:UIScene.ConnectionOptions)
示例
func scene(_ scene: UIScene, willConnectTo session: UISceneSession,
options connectionOptions: UIScene.ConnectionOptions) {
if let windowScene = scene as? UIWindowScene {
self.window = UIWindow(windowScene: windowScene)
let initialViewController =
storyboard.instantiateViewController(withIdentifier: "voiceoverViewController")
self.window!.rootViewController = initialViewController
self.window!.makeKeyAndVisible()
}
}