我有一个UICollectionView,其中有许多UICollectionViewCell,每个UICollectionViewCell都有一个UIButton。每次用户按下这些UIPopoverController之一时,我都会显示一个UIButton。然而,当我这样做的时候,UIPopoverController的位置并不是正确的。我的猜测是,这是由于我正在使用的CGRect中的翻译问题,但在我的一生中,我无法想出如何纠正它。在我的选择器中,当UIButton被按下时,我有这样的东西.
UIButton *detailsButton = (UIButton *)sender;
[self.popoverController presentPopoverFromRect:detailsButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];但是,当我这样做时,它似乎每次都位于同一个位置,而不管UIButton和UICollectionViewCell在UICollectionView中的位置如何。有人能给我一些指点,说明我如何在整个UIButton中翻译UICollectionView的位置吗?我想我需要detailsButton的绝对位置,但不知如何获得它。
感谢您的任何帮助!
发布于 2014-06-24 15:33:09
视图的坐标相对于其superview,而不是相对于屏幕。因此,如果您的所有单元格都相同,则所有按钮的detailsButton.frame都是相同的。
尝试更改inView:参数。
[self.popoverController presentPopoverFromRect:detailsButton.frame inView:detailsButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];https://stackoverflow.com/questions/24389227
复制相似问题