2015-09-25 3 views
1

Я огляделся, никто не имеет ответа в Swift, так что вот оно. Я получаю сообщение о том, что в игровой сцене нет члена с именем presentViewController.Как представить UIAlert в Skscene SWIFT

var alertController = UIAlertController(title: "Nothing Selected", 
             message: "You have not selected a picture.", 
           preferredStyle: UIAlertControllerStyle.Alert)  
alertController.addAction(UIAlertAction(title: "Dang!", 
             style: UIAlertActionStyle.Cancel, 
             handler: nil)) 
self.presentViewController(alertController, 
          animated: true, 
         completion: nil) 

ответ

2

В последней строке кода, вместо

self.presentViewController(alertController, animated: true, completion: nil) 

попробовать

self.view?.window?.rootViewController?.presentViewController(alertController, animated: true, completion: nil) 

Это работает для меня. :)

+1

Пришел с 2017 года с той же проблемой и сумел найти тот же ответ, который помог мне более года назад. лол спасибо. Все еще работает с iOS 10 и Swift 3. –

Смежные вопросы