TableView 弹出窗口未关闭 [selfmissPopoverAnimated:YES];

发布于 2025-01-05 02:04:39 字数 419 浏览 1 评论 0原文

我有一个弹出窗口,显示带有多个单元格的表格视图。当触摸单元格时,它会调用以下代码:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Cell check %@", [totalArray objectAtIndex:indexPath.row]);
    [self dismissPopoverAnimated:YES];
}

我知道调用此方法是因为 NSLOG 按应有的方式显示文本。问题是弹出窗口没有被关闭。我认为

[self dismissPopoverAnimated:YES];

应该关闭弹出窗口? 我做错了什么?

I have a popover that displays a tableview with several cells. When a cell is touched, it calls this code:

(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    NSLog(@"Cell check %@", [totalArray objectAtIndex:indexPath.row]);
    [self dismissPopoverAnimated:YES];
}

I know this method is called because the NSLOG displays text like it should. The problem is that the popover is not dismissed. I thought that

[self dismissPopoverAnimated:YES];

should dismiss the popover?
What am I doing wrong?

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

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

发布评论

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

评论(2

甜警司 2025-01-12 02:04:39

您需要在弹出窗口上调用 dismissPopoverAnimated:,而不是在视图或视图控制器上。
尝试调用 [myPopover DismissPopoverAnimated:YES];

You need to call dismissPopoverAnimated: on your popover, not on your view or view controller.
Try to call [myPopover dismissPopoverAnimated:YES];

猫性小仙女 2025-01-12 02:04:39

为了以编程方式关闭弹出窗口,您需要设置一个委托,因为连接到弹出窗口的视图是必须执行关闭操作的视图。检查这个: https://developer.apple .com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/Popovers.html

In order to programmatically dismiss a popover, you need to set a delegate because the view that segued to the popover is the one that has to do the dismiss. Check this: https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/Popovers.html

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