在新的xcode4.2中实现一个简单的popover并捕获dismissPopover事件

发布于 12-14 01:38 字数 325 浏览 8 评论 0原文

我放弃并需要一些帮助。

我正在尝试使用故事板在 xcode4 中实现一个简单的选择器弹出窗口,

我创建了一个故事板并添加了一个选择器视图。我已将一个按钮链接到视图,并显示带有选择器的视图。出现选择器弹出窗口,我可以选择我想要的值。当我关闭弹出窗口时,我没有收到任何事件。之前,在调用视图中调用了“popoverControllerDidDismissPopover”方法。从这里我可以执行任何弹出窗口后操作并检索我根据选择器选择计算的任何特定结果。这一切以前都是有效的。

使用故事板时“popoverControllerDidDismissPopover”相当于什么

谢谢

I give up and need some help.

I am trying to implement a simple picker popover in xcode4 using the story board

I have created a storyboard and added a view which is a picker. I have linked a button to the view, and the view with the picker is displayed. The picker popover appears and I can select the value I want. When I dismiss the popover, I get no event. previously the method "popoverControllerDidDismissPopover" was called in the calling view. From here I could perform any post popover operations and retrieve any specific resultsI had calculated on the basis of the picker selection. This was all working previously.

What is the equivalent of the "popoverControllerDidDismissPopover" when using storyboards

Thanks

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

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

发布评论

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

评论(2

萌面超妹2024-12-21 01:38:54

让“拥有”popover/segue 的视图控制器使用 popoverControllerDidDismissPopover 方法实现 UIPopoverControllerDelegate 协议。另外,请确保在 Interface Builder 中为您的 Segue 分配了一个标识符。然后,实现 prepareForSegue 方法:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender  
{
  if ([segue.identifier isEqualToString:@"MyPopoverSegueIdentifier"]) {
    UIStoryboardPopoverSegue* popSegue = (UIStoryboardPopoverSegue*)segue;
    popSegue.popoverController.delegate = self;
    // also set any properties of the popover view controller itself:
    // popSegue.destinationViewController.someProperty = xyz
  }
}

现在您将按预期收到 popoverControllerDidDismissPopover 消息。

Have your view controller that "owns" the popover/segue implement the UIPopoverControllerDelegate protocol, with the popoverControllerDidDismissPopover method. Also, make sure your segue is assigned an identifier in Interface Builder. Then, implement the prepareForSegue method:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender  
{
  if ([segue.identifier isEqualToString:@"MyPopoverSegueIdentifier"]) {
    UIStoryboardPopoverSegue* popSegue = (UIStoryboardPopoverSegue*)segue;
    popSegue.popoverController.delegate = self;
    // also set any properties of the popover view controller itself:
    // popSegue.destinationViewController.someProperty = xyz
  }
}

Now you'll receive the popoverControllerDidDismissPopover messages as expected.

我要还你自由2024-12-21 01:38:54

我不知道 xcode 等效项,因为我是 MonoTouch 用户,但我确实知道当您以编程方式关闭弹出窗口时,不会触发 DidDismiss 事件(请参阅 Apple 文档)。仅当用户选择另一个元素而关闭弹出窗口时才会调用它。

为了在 MonoTouch 中解决这个问题,我们必须子类化 UIPopoverController,添加我们自己的事件,重写 Dismiss 方法,并在重写方法中触发新事件。这样,无论弹出窗口是通过编程方式还是由用户关闭,都会调用它。

I don't know the xcode equivalent since I am a MonoTouch user, but I do know that the DidDismiss event is not fired when you programatically dismiss the popover (see the Apple documentation). It is only called when the popover is dismissed by the user selecting another element.

To resolve this issue in MonoTouch, we had to subclass the UIPopoverController, add our own event, override the Dismiss method, and fire the new event in the override method. This way, it is called whether the popover is dismissed programatically or by the user.

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