Question

Alright, so I made a popover from my main view and all that good stuff. But I want to have my popover call an action in my main view when a button within the popover is pressed.

MainView *mainView = [[MainView alloc] initWithNibName:@"MainView" bundle:nil]; [mainView doStuff];

The "dostuff" function changes some elements within the view. For example, the color of the toolbar is supposed to be changed. I've put a print command and the print command executes. But for some reason, the toolbar won't change color.

  • I've imported the header of MainView into the popover.
  • I did an @class thingy for MainView in my popover.
  • doStuff is declared in MainView's header.
  • The IBOutlets are declared too, and connected.

Any ideas?

Was it helpful?

Solution

Well its disappointing that we have no direct method that can be used to check in which view (view controller) the popover is shown. The thing that I am doing in tabbased application is:

New_iPadAppDelegate *appDel = (New_iPadAppDelegate *)[[UIApplication sharedApplication] delegate];
    NSArray *viewConts = [(UINavigationController *)[[appDel tabBarController] selectedViewController] viewControllers];
    MainViewController *viewController =  (MainViewController *)[viewConts lastObject];
    if([[viewController popoverController] isPopoverVisible]){
        [viewController doStuff];
    }

Hope this helps,

I know this is not the best way, hoping apple thinks about this issue, or if somebody has devised a work around.

Thanks,

Madhup

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top