我正在尝试从视图切换到另一个视图,代码运行,但没有任何视图被推送。是不是由于视图无法弹出并同时推送?
pushview :
func showChatControllerForGroup(_ user: [User], groupName: String) {
let storyboard = UIStoryboard(name: "Main", bundle: nil)
let vc: GroupChatMessangingViewController = storyboard.instantiateViewController(withIdentifier: "GroupChatMessangingViewController") as! GroupChatMessangingViewController
vc.group?.members = user
vc.group?.name = groupName
self.navigationController?.pushViewController(vc, animated: true)
}
弹出
let transition = CATransition()
transition.duration = 0.5
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionReveal
transition.subtype = kCATransitionFromBottom
navigationController?.view.layer.add(transition, forKey: nil)
_ = navigationController?.popViewController(animated: true)
let user = self.chosenUser
self.nextVC.showChatControllerForGroup(user, groupName: self.groupNameTextField.text!)
答案 0 :(得分:0)
在pop viewcontroller
之前调用delegate方法let transition = CATransition()
transition.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
transition.type = kCATransitionReveal
transition.subtype = kCATransitionFromBottom
navigationController?.view.layer.add(transition, forKey: nil)
let user = self.chosenUser
self.nextVC.showChatControllerForGroup(user, groupName: self.groupNameTextField.text!)
_ = navigationController?.popViewController(animated: true)
答案 1 :(得分:0)
为PushViewController尝试此语法:
let nextVC = self.storyboard?.instantiateViewController(withIdentifier: "NextViewController") as! NextViewController
self.navigationController?.pushViewController(nextVC, animated: true)
对于pop:
self.navigationController?.popViewController(animated: true)