从弹出窗口调用函数

发布于 2024-08-25 08:36:19 字数 462 浏览 3 评论 0原文

好吧,所以我从我的主视图中制作了一个弹出窗口以及所有这些好东西。但我想让我的弹出窗口在按下弹出窗口中的按钮时在主视图中调用一个操作。

MainView *mainView = [[MainView alloc] initWithNibName:@"MainView" 包:nil]; [mainView doStuff];<​​/code>

“dostuff”函数更改视图中的一些元素。例如,应该更改工具栏的颜色。我已经输入了打印命令并且执行了打印命令。但由于某种原因,工具栏不会改变颜色。

  • 我已将 MainView 的标题导入到弹出窗口中。
  • 我在我的弹出窗口中为 MainView 做了一个@class 的事情。
  • doStuff 在 MainView 的标头中声明。
  • IBOutlet 也被声明并连接。

有什么想法吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

尘世孤行 2024-09-01 08:36:19

令人失望的是,我们没有直接的方法可以用来检查弹出窗口显示在哪个视图(视图控制器)中。我在基于选项卡的应用程序中所做的事情是:

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];
    }

希望这有帮助,

我知道这不是最好的方法,希望苹果考虑这个问题,或者是否有人设计了解决方法。

谢谢,

马杜普

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

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文