AlertController is not in the window hierarchy

前端 未结 8 1734
北荒
北荒 2020-11-29 03:01

I\'ve just created a Single View Application project with ViewController class. I would like to show a UIAlertController from a function which is located inside my own class

8条回答
  •  -上瘾入骨i
    2020-11-29 03:19

    If you want to create a separate class for displaying alert like this, subclass NSObject not UIViewController.

    And pass the ViewControllers reference from which it is initiated, to the showAlert function so that you can present alert view there.

提交回复
热议问题