Call function from popover

Well, that's why I made a popover from my main view and all this good stuff. But I want my popover to trigger an action in my main view when the button inside the popover is pressed.

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

The dostuff function changes some elements in the view. For example, the color of the toolbar must be changed. I placed the print command and executed the print command. But for some reason, the toolbar will not change color.

  • I have imported the MainView header into a popover.
  • I made the @class class for MainView in my popover.
  • doStuff is declared in the MainView header.
  • IBOutlets are also advertised and connected.

Any ideas?

+4
source share
1 answer

It’s good that he is disappointed that we don’t have a direct method that can be used to check in which view (view controller) a popover is displayed. What I'm doing in a tabbed app 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 the apple will think about this problem, or if someone has developed a job.

Thanks,

Madhup

+1
source

Source: https://habr.com/ru/post/1304410/


All Articles