Trouble ๐
๐ฅ ๋ฌธ์ ์
- tableView ๋ collecitonView ์
์์ ํน์ ์
์ frame์์ popover๋ฅผ ๋์ฐ๊ธฐ ์ํด ์
์์ฒด์ GestureRecognizer ์ฝ์
ํ์์
- Gesture๋ฅผ ์ธ์ํ๋ฉด delegate๋ฅผ ํตํด colletionView๋ tableView์ frame์ ๋๊ฒจ์ฃผ์ด pop ์ค๋ฒ๋ฅผ ๋์ ์
- ํ์ง๋ง ์ด๋ ๊ฒ frame์ ๋๊ฒจ์ฃผ๋ฉด Cell์ด init๋ ๋๋ง frame์ด ์
๋ฐ์ดํธ๋๊ณ reuse๋ ๋๋ update๋์ง ์๊ธฐ ๋๋ฌธ์ ์ด์ frame์ popover๋ฅผ ๋์ฐ๋ ๋ฌธ์ ๊ฐ ์๊น
๐ ํด๊ฒฐ์ฑ
- tableView ๋ collecitonView์์ฒด์ GestureRecognizer๋ฅผ ๋ฃ์ด์ค
- ๊ทธ ํ๋ก tableView๋ rectForRow ๋ฉ์๋๋ฅผ ์ฌ์ฉํ์ฌ ์ฌ์ฉ์๊ฐ ํฐ์นํ๊ณณ์ ์
์ ์ฐพ์ ์ ์์
- collectionView๋ layoutAttributesForItem ๋ฉ์๋์ convert ๋ฉ์๋๋ฅผ ํตํด ์ ํํ cell์ ํ๋ ์์ ์ฐพ์์ฌ ์ ์๋ค
let touchPoint = sender.location(in: sender.view)
guard let indexPath = collectionView.indexPathForItem(at: touchPoint) else {
return
}
guard let theAttributes = collectionView.layoutAttributesForItem(at: indexPath) else {
return
}
let cellFrame = collectionView.convert(theAttributes.frame, to: collectionView.superview)
์ถ์ฒ๐
๐Apple Docs: rectForRow(at:)
๐ stackoverflow