pushViewController 在 swift 3 中不起作用
pushViewController not work in 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)
}
我添加按钮以通过此代码查看:
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 设置如下:
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)
}