pushViewController 在 swift 3 中不起作用

初津

我添加按钮以通过此代码查看:

btnMarkerInfo.setImage(imgInfo, for: .normal)
btnMarkerInfo.setTitleColor(UIColor.white, for: .normal)
btnMarkerInfo.frame = CGRect(x: w, y: UIScreen.main.bounds.height-70-56, width: 56, height: 56)
btnMarkerInfo.addTarget(self, action: #selector(vcMain.markerDidTap(_:)), for: .touchUpInside)
btnMarkerInfo.isHidden = true
btnMarkerInfo.alpha = 0
self.view.addSubview(btnMarkerInfo)

markerDidTap() 在这里:

func markerDidTap(_ sender: UIButton){
    let vcPointTitles = storyboard?.instantiateViewController(withIdentifier: "vcPointTitles") as! vcPointTitles
    vcPointTitles.pointId = sender.tag
    self.navigationController?.pushViewController(vcPointTitles, animated: false)
}

当用户点击此按钮功能markerDidTap运行且vcPointTitles必须显示时,功能执行但 vcPointTitles 不显示。class 和 storyBoardId 设置如下:视图控制器类和信息vcPointTitles 定义如下:

class vcPointTitles: UIViewController, UITableViewDelegate, UITableViewDataSource { .... }

我怎样才能解决这个问题?

神童

试试这个,虽然来晚了,但这可以帮助其他人面临这样的

func markerDidTap(_ sender: UIButton){
   let storyBoard: UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
   let vcPointTitles = 
       storyBoard.instantiateViewController(withIdentifier: "vcPointTitles") as! 
       VCPointTitlesViewController
    vcPointTitles.pointId = sender.tag

   self.present(vcPointTitles, animated: true, completion: nil)
}

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章