How to update Superview from its Subview in iPad?

非 Y 不嫁゛ 提交于 2019-12-05 09:41:38

问题


I have a UISegmentedController i have 3 UIViewControllers Like photos,frames,gallery. I add those 3 Views in Superview Using 'addSubView'. In frames view i have added a subview that name as EditView. In EditView i have done some changes, i want to update these changes in frames view. But when am removing EditView from frames view any single method doesn't calling. Then how to update the changes from subview in superview. Tree: UISegmentedController -> Frames(Su) -> EditViews(Subview). Can any one help me..


回答1:


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




回答2:


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.




回答3:


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.



来源:https://stackoverflow.com/questions/6302346/how-to-update-superview-from-its-subview-in-ipad

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