How to present UIAlertController when not in a view controller?

前端 未结 30 3535
庸人自扰
庸人自扰 2020-11-22 06:21

Scenario: The user taps on a button on a view controller. The view controller is the topmost (obviously) in the navigation stack. The tap invokes a utility class method call

30条回答
  •  耶瑟儿~
    2020-11-22 06:54

    You can send the current view or controller as a parameter:

    + (void)myUtilityMethod:(id)controller {
        // do stuff
        // something bad happened, display an alert.
    }
    

提交回复
热议问题