views:

718

answers:

1

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?

A: 

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

Madhup
Seems like a work-around to me :)
Jann
@Jann I don't know what you think but its the way apple also does see their refernce codes for splitview controllers http://developer.apple.com/iphone/library/documentation/General/Conceptual/iPadProgrammingGuide/UserInterface/UserInterface.html#//apple_ref/doc/uid/TP40009370-CH3-SW2
Madhup