开发者

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 calli开发者_高级运维ng. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜