私はUINavigationControllerのdelegate
プロパティを利用するいくつかのカスタムコントローラトランジションで作業しています。 viewDidLoad()
に設定すると、プッシュ後のある時点でself.navigationController?.delegate
が割り当て解除されます。 viewWillAppear()
でそれを設定するが、私はそのプロパティが最初に割り当て解除され、人々が通常このプロパティを設定する理由は不思議です。どこにUINavigationControllerのデリゲートプロパティを設定する必要がありますか?
// The first time you push, it will work correctly, and the delegate function below is called. After you pop back to this controller, delegate is nil (has been deallocated)
override func viewDidLoad() {
super.viewDidLoad()
self.navigationController?.delegate = self
}
// Brute force works
override func viewWillAppear(_ animated: Bool) {
self.navigationController?.delegate = self
}
func navigationController(_ navigationController: UINavigationController,
animationControllerFor operation: UINavigationControllerOperation,
from fromVC: UIViewController,
to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning?
{
if operation == .push {
return WTPPushAnimator()
}
if operation == .pop {
return WTPPopAnimator()
}
return nil;
}
ポップされていません。 NavigationControllerのルートコントローラです。 – GoldenJoe
デリゲートの値にウォッチブレークポイントを設定して、誰がそれをnilに戻しているかを調べることをお勧めします。 – vacawama
私は組み立てがうまくいかない。 – GoldenJoe