Navigation bar issue with landscape mode

68 views Asked by At

I am applying the landscape mode to only one view controller. In that view controller, I am using the collections view. Everything is working fine in portrait mode. In landscape, mode data shows perfectly except for the navigation bar title and back button. I am attaching the images

Portrait Mode

enter image description here

Landscape mode

enter image description here

I am using the below code for the landscape mode

extension UIApplication {

    class func getTopViewController(base: UIViewController? = UIApplication.shared.keyWindow?.rootViewController) -> UIViewController? {
        
        if let nav = base as? UINavigationController {
            return getTopViewController(base: nav.visibleViewController)
        }

        if let tab = base as? UITabBarController {
            if let selected = tab.selectedViewController {
                return getTopViewController(base: selected)
            }
        }

        if let presented = base?.presentedViewController {
            return getTopViewController(base: presented)
        }

        return base
    }

}

Created protocol

protocol Rotatable {}

and calling

class ComparePlans: UIViewController, UICollectionViewDelegateFlowLayout, UICollectionViewDelegate, UICollectionViewDataSource, Rotatable {

I don't know exactly what the issue is. I tried different ways. Any help would appreciate it.

My storyboard page image

enter image description here

0

There are 0 answers