uitabbar中的按钮不会推动任何视图控制器swift 3

时间:2017-09-03 14:56:30

标签: swift xcode

我在tabbarcontroller中添加了一个按钮作为子视图来打开相机和图库。它工作正常,但每当需要推动视图控制器时,它什么都不做。我删除了调用相机和图库的功能,它只需在控制台中打印文本即可。意思是按钮工作正常,但是当推动/呈现VC时,什么都没有..

与插入标签栏的子视图的按钮有关吗?它应该是像Instagram一样中间的那些大按钮之一。

我已经将VC作为UITabbarcontroller的子类推送。仍然没有..

这是我的代码:

 override func viewDidLoad() {
    super.viewDidLoad()


    myPickerController.delegate = self

    let sell_image = UIImage(named: "Sell icon")

    button.setImage(sell_image, for: .normal)
    button.setTitle("Sell", for: .normal)
    self.view.insertSubview(button, aboveSubview: self.tabBar)

    button.addTarget(self, action: #selector(sellVC(sender:)), for: .touchUpInside)


}

然后按钮功能本身:

 func sellVC(sender:UIButton!) {

  print("this button prints this successfully but doesn't push the VC below")

    let vc = self.storyboard?.instantiateViewController(withIdentifier: "dummy") as! DummyViewController
    self.navigationController?.pushViewController(vc, animated: true)
}

0 个答案:

没有答案