uicollectionviewcell

Swift -AVPlayer' KVO in cell's parent vc causing Xcode to freeze

折月煮酒 提交于 2021-01-27 20:51:02
问题 I have a cell that takes up the entire screen so there is only 1 visible cell at a time. Inside the cell I have an AVPlayer. Inside the cell's parent vc I have a KVO observer that listens to the "timeControlStatus" . When the player stops playing I call a function stopVideo() inside the cell to stop the player and either show a replay button or a play button etc. 3 problems: 1- When the video stops/reaches end if I don't use DispatchQueue inside the KVO the app crashes when the cell's

How do I delete an item in a collection view with a button in the cell?

痴心易碎 提交于 2021-01-01 09:40:10
问题 It seems like it should be easy to do, but how do I delete the item at the indexPath when the "X" button in the cell is tapped? Do I create an IBAction in the Cell class? If so, how do I pass in the indexPath.item? In some research I have done, I've seen people use notifications and observers, but it seems to be overcomplicated. Can someone provide a basic solution for deleting a cell at the indexPath with a delete button? I am using Realm to persist the items, but I'm having trouble knowing

Detecting closest collectionviewcell to the center of the collectionview

最后都变了- 提交于 2020-12-29 06:18:29
问题 Suspect I am doing something fundamentally wrong below... I have a horizontal collectionview and after dragging I want to snap the closest cell to the center. But my results are unpredictable... what am I doing wrong here? func scrollViewDidEndDragging(scrollView: UIScrollView, willDecelerate decelerate: Bool) { // Find collectionview cell nearest to the center of collectionView // Arbitrarily start with the last cell (as a default) var closestCell : UICollectionViewCell = collectionView

Image in collectionView cell causing Terminated due to memory issue

拟墨画扇 提交于 2020-12-15 05:18:10
问题 I looked at several answers for this problem but none helped. vc1 is a regular vc, I grab 20 images from firebase, in vc2 I use ARKit to display those images upon user selection. I have a collectionView in vc2 that paginates 20 more images from firebase. The problem is when the next 20 images are loading and I start scrolling, the app crashes with Message from debugger: Terminated due to memory issue . When scrolling those new images, I look at the memory graph and it shoots up to 1 gig, so

Image in collectionView cell causing Terminated due to memory issue

烈酒焚心 提交于 2020-12-15 05:17:51
问题 I looked at several answers for this problem but none helped. vc1 is a regular vc, I grab 20 images from firebase, in vc2 I use ARKit to display those images upon user selection. I have a collectionView in vc2 that paginates 20 more images from firebase. The problem is when the next 20 images are loading and I start scrolling, the app crashes with Message from debugger: Terminated due to memory issue . When scrolling those new images, I look at the memory graph and it shoots up to 1 gig, so