Search code examples
iphoneobjective-cipadsubviewsuperview

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


Solution

  • 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