I created a navigation item button in the tab bar controller.
class TabBarContoller: UITabBarController,UIPopoverPresentationControllerDelegate {
...
let languageBtn = UIBarButtonItem(title: "EN", style: UIBarButtonItemStyle.Plain, target: self, action: #selector(Language))
// navigationItem.rightBarButtonItem = [rightButton , languageBtn]
navigationItem.setRightBarButtonItems([rightButton,languageBtn], animated: true)
i want to run this function when this button it checked, which will popover a view controller:
func showLanguagePopOver(base: UIView) {
let popOverContent = self.storyboard?.instantiateViewControllerWithIdentifier("Languages")as! Languages
popOverContent.preferredContentSize = CGSizeMake(150, 150)
let nav = UINavigationController(rootViewController: popOverContent)
nav.modalPresentationStyle = .Popover
let popOver = nav.popoverPresentationController
popOver?.delegate = self
popOver?.sourceView = base
popOver?.sourceRect = base.bounds
popOver?.sourceRect = CGRect(x: 0, y: 0, width: 100, height: 25)
self.presentViewController(nav, animated: true, completion: nil)
}
i tried to call it like that :
func Language()
{
showLanguagePopOver(UIView)
}
it didn't work, any help?
Change below line:
showLanguagePopOver(UIView)
with this line:
showLanguagePopOver(self.view)