Tabbar Item in Swift

≡放荡痞女 提交于 2019-12-24 08:30:07

问题


I have some issue in Tabbar controller. I put "FAQ" tab bar item in the bottom. When the app runs on the small screen devices, it automatically appears in More section.



The problem is that I put "Nav Bar" in FAQ view controller. For large screens (ipad), FAQ bar item shows in bottom. When Navbar item goes to More section, navbar is appear as two bar. One bar is that I make and another bar is default bar.
My current problem solving way is

 if (UIDevice.current.userInterfaceIdiom == UIUserInterfaceIdiom.pad)
    {   //ipad
       navBar.isHidden = false


    }
    else {
         navBar.isHidden = true

    }


I don't know that way is right or wrong.
Please help me how to remove Navbar when it appears in small screen. Now, I am using Swift 3 (Xcode 8).

English Language is not my native language. I'm sorry for my english grammar.


回答1:


For your use case, you can try this,

`if UIScreen.main.sizeType == .iPhone6Plus || UIScreen.main.sizeType == .iPhonePlus || UIScreen.main.sizeType == .iPhone6 || UIScreen.main.sizeType == .iPhoneX || UIScreen.main.sizeType == .iPhone5 {
     // for available iPhones
     navBar.isHidden = true
} else {
    // for iPad
    navBar.isHidden = false
}`

Basically, I am checking for all the available sizes of iPhones here and then doing what you want, accordingly. You can also manage your navigation bar in the viewDidAppear or viewDidLoad of the controller if you want. Do upvote the answer if this helps you. Feel free to comment for any other query or discussion. Happy Learning.



来源:https://stackoverflow.com/questions/40623798/tabbar-item-in-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!