Categories
Mastering Development

how to pass id Realm in UICollectionView to UITableView

I am creating an app that shows all the favorite movies from theMovieDB, I have already created the list of movies with UICollectionView, and the UITableView for favorites, using Realm to do data persistence. However to do the details part of the film, I am not able to do it. When I touch the selected […]

Categories
Mastering Development

swift different number of cell in each section

I’m trying to pull data from firebase and show it in a collectionView with sections. How can add a different number of cells per section as each firebase data node will not have the same number of posts. var users = [User]() var posts = [Post]() Updated collection view methods: override func collectionView(_ collectionView: UICollectionView, […]

Categories
Development

Set UICollectionViewCell size before content size

I have a UICollectionView with dynamic cell sizing which was working perfectly until I set proportional width constraints on the content inside the cell. It seems now the UICollectionViewCell is sized to the size of the content, whereas actually I want the opposite – the content needs to be sized proportional to the cell size. […]

Categories
Development

UICollectionViewLayout – 3 cells in 2 columns

I am trying to create a UICollectionView with a 7-cell repeating layout that looks like this: However, with CollectionViewLayout, I can’t seem to get the 6th and 7th cell into the same column. Here’s the relevant code: func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let collectionViewWidth = self.collectionView.bounds.width let […]

Categories
Development

Trying to implement a drawing function in Swift 5 using touch

iv been working on an app with existing code from a previous team and a few of us have been working on it for quite some now and nothing we seem to do will get the strokes to display. We have a few files, one called TraceViewController, with a UICollectionView with a selection of all […]

Categories
Development

Collection View layout bug when selectItem (Swift 5)

After selecting cell from viewDidLoad Layout is change Before select cell After select cell let indexPath = IndexPath(row: SelectedFolderIndex, section: 0) collectionView.selectItem(at: indexPath, animated: false, scrollPosition: .centeredVertically) Layout func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { return CGSize(width: collectionView.frame.width/2.2, height: 55) }

Categories
Development

Why is my UICollectionViewCell not getting data from UICollectionViewController?

I have a UICollectionViewController called SwipingController that creates a TeamCell and gives it a teamName of “Boston Celtics” class SwipingController: UICollectionViewController, UICollectionViewDelegateFlowLayout { override func viewDidLoad() { super.viewDidLoad() collectionView?.backgroundColor = .white collectionView?.register(TeamCell.self, forCellWithReuseIdentifier: “cellId”) collectionView?.isPagingEnabled = true } func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat { return 0 } override […]

Categories
Development

How can I make a collectionview header?

I have a problem setting up the collectionView header , I implemented the two functions of UICollectionViewDelegateFlowLayout , but I still don’t have my header in my view and the attached code demonstrates what I have implemented inside the two functions class UserProfileController:UICollectionViewController,UICollectionViewDelegateFlowLayout { override func viewDidLoad() { super.viewDidLoad() collectionView?.backgroundColor = .white collectionView?.register(UserProfileHeader.self, forSupplementaryViewOfKind: UICollectionView.elementKindSectionHeader, […]

Categories
Development

Copyable TextView content inside CollectionView Cell Swift 5

I want to implement a custom context menu by tapping on a Collection View cell that will consist of Copy, Report and Block features. The problem is that after I have implemented the menu itself, I added a TextView and now nothing seems to be working anymore. The menu does not show up, neither textview […]

Categories
Development

How to set no spacing in UICollectionViewDelegateFlowLayout?

I’m trying to do a UICollectionViewDelegateFlowLayout with 3 items to a row at a third of the screen width. For some reason it’s adding spacing and not conforming to the square layout. Here are the UICollectionViewDelegateFlowLayout functions. func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize { let yourWidth = (collectionView.bounds.width/3.0) – […]