【问题标题】:Adding ChildViewController to UIAlertController将 ChildViewController 添加到 UIAlertController
【发布时间】:2016-04-01 19:04:02
【问题描述】:

我想在我的警报对话框中拥有一个自定义视图以及“确定”和“取消”按钮。 我想在运行时在 alertViewController 中注入一个 viewController。虽然它继承自 ViewController 但documentation 明确指出

UIAlertController 类旨在按原样使用,不支持子类化。此类的视图层次结构是私有的,不得修改。

有没有其他方法可以完成这项工作。

【问题讨论】:

    标签: ios objective-c iphone ipad viewcontroller


    【解决方案1】:

    正如消息所述,您不能继承 UIAlertController。只需按原样使用它并使用UIAlertAction 添加您要执行的操作(“确定”、“取消”等)。

    如果这不能满足您的需求,您将必须创建一个新的 ViewController(xib 和类)并将其设计为看起来和做您想要的。

    【讨论】:

    • 这是我想避免编写另一个视图控制器的原因。警报对话框无需大量编码即可完成大量工作
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-17
    • 1970-01-01
    • 1970-01-01
    • 2018-11-27
    • 2014-12-08
    • 2015-10-19
    相关资源
    最近更新 更多