0

I had a view controller which is initialised in appdelegate.I was added that viewcontroller to the navigation controller with addsubview methode,inorder to show it above the navigation bar.Now i am adding another viewcontrollers view as the subview of this view.Now when i am pressing a button on the subview i need to perform some methodes in the superview.I tried this way`

appdelegate.viewcontroller =(ViewController*)self.view.superview;  

    }
    if(appdelegate.viewcontroller==nil)
    {

        NSLog(@"appdelegate viewcontroller nil"); 

    }
    else
    {

    [appdelegate.viewcontroller setmessage:@""];
     }

`But it is giving me error like

[UIView setmessage:]: unrecognized selector sent to instance.Can anybody point me in where i am going wrong?

hacker
  • 8,919
  • 12
  • 62
  • 108
  • This link is not exactly related to your que . But it may be helpful ---**http://stackoverflow.com/questions/6302346/how-to-update-superview-from-its-subview-in-ipad?rq=1** – Kumar KL Jul 01 '13 at 08:50

1 Answers1

0
for (UIView* next = [self.view superview]; next; next = next.superview) 
    {
        UIResponder* nextResponder = [next nextResponder];
        if ([nextResponder isKindOfClass:[UIViewController class]])
        {
            [(UIViewController*)nextResponder viewWillAppear:YES];
        }
    }
lakshmen
  • 28,346
  • 66
  • 178
  • 276
  • how i will assign this to a viewcontroller object? – hacker Jul 01 '13 at 09:15
  • appdelegate.viewcontroller = [self viewController]; – lakshmen Jul 01 '13 at 09:25
  • [self superview] giving me a warning as there is no instance methode and gone when i changed to [self.view superview] but the actual error stays..also assigning like this giving me assigning incompatable pointer type assigning to – hacker Jul 01 '13 at 09:32
  • u are doing this in the appdelegate? don't do it in appdelegate.. do it in the viewcontroller, you will be calling the superview. – lakshmen Jul 01 '13 at 09:39
  • i am doing it in viewcontroller – hacker Jul 01 '13 at 09:39