Problem UICollectionViewController When Trying to Use bringSubview Swift 4

Hi guys, I found unique issue when trying to use bringSubview in UICollectionViewController. The method doesn't work if you try like this.

UICollectionViewController has a diffrent to do add subview. Because it's not pure UIViewController itself or parent. It needs to get superview to add a new view.

So basically you do like below and nothing happened or it doesn't work. Don't worry about it, i have a solution for you. It's simple way to do it and don't make you think too much. I find this idea on stackoverflow. I will put the link below.

self.view!.bringSubview(toFront: something)

So to do trick you need to use superview!.

self.view!.superview!.bringSubview(toFront: something)

reference :

Popular posts from this blog

Missing system image Android Studio solution

How to restart the app with flutter Android and iOS

How to get thumbnail from video URL in Swift 5