繁体   English   中英

UIPopoverController通过UITableViewCell

[英]UIPopoverController over 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];

谢谢你的帮助

您应该将单元格作为视图传递。 很可能你会想要传递rect的单元格边界(cell.bounds,而不是cell.frame)。

一旦用户滚动列表,上面的方法似乎对我不起作用。 找到相对于滚动量的单元格位置是诀窍。

CGRect rect = [tableView convertRect:[tableView rectForRowAtIndexPath:indexPath]
    toView:tableView]; 

[popoverController presentPopoverFromRect:rect
    inView:tableView
    permittedArrowDirections:UIPopoverArrowDirectionAny
    animated:YES];

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM