首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >UIPopoverControl on UIButton on?

UIPopoverControl on UIButton on?
EN

Stack Overflow用户
提问于 2014-06-24 14:26:52
回答 1查看 202关注 0票数 1

我有一个UICollectionView,其中有许多UICollectionViewCell,每个UICollectionViewCell都有一个UIButton。每次用户按下这些UIPopoverController之一时,我都会显示一个UIButton。然而,当我这样做的时候,UIPopoverController的位置并不是正确的。我的猜测是,这是由于我正在使用的CGRect中的翻译问题,但在我的一生中,我无法想出如何纠正它。在我的选择器中,当UIButton被按下时,我有这样的东西.

代码语言:javascript
复制
UIButton *detailsButton = (UIButton *)sender;
[self.popoverController presentPopoverFromRect:detailsButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

但是,当我这样做时,它似乎每次都位于同一个位置,而不管UIButtonUICollectionViewCellUICollectionView中的位置如何。有人能给我一些指点,说明我如何在整个UIButton中翻译UICollectionView的位置吗?我想我需要detailsButton的绝对位置,但不知如何获得它。

感谢您的任何帮助!

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-06-24 15:33:09

视图的坐标相对于其superview,而不是相对于屏幕。因此,如果您的所有单元格都相同,则所有按钮的detailsButton.frame都是相同的。

尝试更改inView:参数。

代码语言:javascript
复制
[self.popoverController presentPopoverFromRect:detailsButton.frame inView:detailsButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/24389227

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档