i create new project in swift,and want create new uiwindow,here code in controller:
override func viewdidload() { super.viewdidload() // additional setup after loading view, typically nib. let mywindow = uiwindow(frame: uiscreen.mainscreen().bounds) mywindow.backgroundcolor = uicolor.redcolor() mywindow.hidden = false }
when run project,i got message: 'application windows expected have root view controller @ end of application launch'.but @ objective-c project,it's ok.
who can tell me what's wrong whit project?
thanks.
finally,i got answer myself.you can't create new uiwindow @ time when loading new viewcontroller,but can after view loaded.here code:
let mywindow = {void->uiwindow in let cwindow = uiwindow(frame: uiscreen.mainscreen().bounds) cwindow.backgroundcolor = uicolor.redcolor() return cwindow }() override func touchesbegan(touches: set<uitouch>, withevent event: uievent?) { mywindow.hidden = false }
Comments
Post a Comment