TableView 弹出窗口未关闭 [selfmissPopoverAnimated:YES];
我有一个弹出窗口,显示带有多个单元格的表格视图。当触摸单元格时,它会调用以下代码:
(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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在弹出窗口上调用
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];
为了以编程方式关闭弹出窗口,您需要设置一个委托,因为连接到弹出窗口的视图是必须执行关闭操作的视图。检查这个: 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