open viewcontroller from tab like in instagram camera page on IOS

前端 未结 3 1760
逝去的感伤
逝去的感伤 2020-12-10 00:17

what i want is suppose to be simple, instagram middle tab on IOS opens the app\'s camera interface but not like the rest of the tabs but as an independet view controller and

3条回答
  •  渐次进展
    2020-12-10 00:24

    SWIFT 4 Code

    After subclassing the Tabbarcontroller as specified by @erparker above, use this code

     override func tabBar(_ tabBar: UITabBar, didSelect item: UITabBarItem) {
            if(item.tag==300){
    
    
                if let viewController = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "addNewTaskView") as? AddNewTaskViewController {
    
                   self.present(viewController, animated: true, completion: nil)
                }
    
            }
        }
    

    here, "Main" is the storyboard name which contains target view controller and "addNewTaskView" is the view controller storyboard Id given at the storyboard for a view controller.

提交回复
热议问题