开发者

Calling function from popover

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 Ma开发者_运维百科inView's header.
  • The IBOutlets are declared too, and connected.

Any ideas?


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

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜