简体   繁体   中英

How to update Superview from its Subview in iPad?

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..

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM