簡體   English   中英

UICollectionViewCell內的UIButton上的UIPopoverControl?

[英]UIPopoverControl on UIButton inside UICollectionViewCell?

我有一個UICollectionView ,其中有許多UICollectionViewCell ,每個UICollectionViewCell中都有一個UIButton 我想在用戶每次按下這些UIButton之一時顯示一個UIPopoverController 但是,當我這樣做時, UIPopoverController的位置遠不正確。 我的猜測是,這是由於我正在使用的CGRect的翻譯問題CGRect ,但是我一生無法弄清楚如何糾正它。 在按下UIButton時調用的選擇器內部,我有類似這樣的內容...

UIButton *detailsButton = (UIButton *)sender;
[self.popoverController presentPopoverFromRect:detailsButton.frame inView:self.view permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

當我這樣做,但是,它每次出現被定位不管位置在同一地點, UIButtonUICollectionViewCell的內UICollectionView 有人可以給我一些關於如何在整個UICollectionView轉換UIButton位置的UICollectionView嗎? 我想我需要detailsButton的絕對位置,但是如何獲取它卻茫然。

謝謝你提供的所有幫助!

視圖的坐標是相對於其父視圖的坐標,而不是相對於屏幕的坐標。 因此,如果所有單元格都相同,則所有按鈕的detailsButton.frame都將相同。

嘗試更改inView:參數。

[self.popoverController presentPopoverFromRect:detailsButton.frame inView:detailsButton.superview permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM