UIPopoverController 通过 UITableViewCell
我想以编程方式在表视图中选择一行,然后显示我的弹出窗口并让箭头指向该单元格。
当表格没有滚动时,此代码可以正常工作,对于滚动表格视图,弹出箭头的位置不正确。
[self.EventsTableView selectRowAtIndexPath:indexPath
animated:YES
scrollPosition:UITableViewScrollPositionMiddle];
[popoverController presentPopoverFromRect:CGRectOffset(cell.frame, 0, cell.frame.size.height + self.EventsTableView.contentOffset)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
感谢您的帮助
I'd like to programmatically select a row in a table view then present my popover and let the arrow points to the cell.
This code works fine when the table has no scrolling, for scrolling table view the popover arrow is positioned incorrectly.
[self.EventsTableView selectRowAtIndexPath:indexPath
animated:YES
scrollPosition:UITableViewScrollPositionMiddle];
[popoverController presentPopoverFromRect:CGRectOffset(cell.frame, 0, cell.frame.size.height + self.EventsTableView.contentOffset)
inView:self.view
permittedArrowDirections:UIPopoverArrowDirectionLeft
animated:YES];
Thanks for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您应该将单元格作为视图传递。您很可能希望传递矩形的单元格边界(cell.bounds,而不是 cell.frame)。
You should pass the cell as the view. Most likely you will want to pass the cell's bounds (cell.bounds, not cell.frame) for the rect.
当用户向下滚动列表时,上述方法似乎对我不起作用。找到相对于滚动量的单元格位置就是诀窍。
Above method didn’t seem to work for me when once the user scrolls the list down. Finding the cell position relative to the scrolled amount was the trick.