How to set parentViewController in UIViewController?

前端 未结 6 828
春和景丽
春和景丽 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:42

    It looks like calling the setParentViewController: method works.

    [childViewController setParentViewController:self];
    

    However this still generates a compiler Warning. Which, IMO, means don't do it (I subclassed instead).

提交回复
热议问题