How to set parentViewController in UIViewController?

前端 未结 6 849
春和景丽
春和景丽 2021-02-13 10:26

The parentViewController property of UIViewController is readonly, but I am nesting custom view controllers and would like to use this property.

However, since it is re

6条回答
  •  佛祖请我去吃肉
    2021-02-13 10:53

    However, since it is readonly, and I found no other way to set this property, my quesion is: how do I set it?

    If it is readonly, you can't use dot notation without getting a compiler error.

    However, you might be able to use categories to add a custom modifyParentViewController method to the UIViewController class.

    Even if the property is readonly, the variable itself might be modifiable, if it is not @protected. If it is @protected, subclassing the view controller may allow you the option of modifying the variable.

提交回复
热议问题