How to update Superview from its Subview in iPad?

Deadly 提交于 2019-12-03 22:41:59
Yuvaraj.M

I found the code to update something in superview from subview. Please use this code in your subview. It will call your superview viewWillAppear method. You can use another method instead of viewWillAppear. It works for me.

for (UIView* next = [self.view superview]; next; next = next.superview) 
    {
        UIResponder* nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]])
        {
            [(UIViewController*)nextResponder viewWillAppear:YES];
        }
    }

-Yuva.M

You could access the super view of any UIView by using the superview property of UIView.

The below statement will be in your EditView.

FrameView* mySuperFrameView = (FrameView*)self.superview;

and the next statement could be calling the super view function.

[mySuperFrameView updateMySuperView];

updateMySuperView is the part of your superview.

Removing a view from its superview releases it.

Submit your changes before removing the editView from its superview. You could overwrite removeFromSuperview in your editView, and do your data manipulation before calling super removeFromSuperview.

Or your view controller could take data from the editView before removing it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!