gpt4 book ai didi

ios - UINavigationControllerDelegate 的方法还不够

转载 作者:行者123 更新时间:2023-11-29 02:10:12 24 4
gpt4 key购买 nike

UINavigationControllerDelegate 只有 2 个委托(delegate)方法可以使用:

  • navigationController:willShowViewController:
  • navigationController:didShowViewController:

但是,如果我想在使用手势交互弹出 viewController 时被调用怎么办?像这样的东西:

  • navigationController:willStartDragging:
  • navigationController:isDraggingWithPercentage:

协议(protocol)中没有这样的委托(delegate)方法。我怎样才能得到这些方法?

最佳答案

您可以像这样向导航 Controller 的 interactivePopGestureRecognizer 添加目标/操作:

[navigationController.interactivePopGestureRecognizer addTarget:self action:@selector(handleInteractivePop:)];

然后跟踪手势的状态

- (void)handleInteractivePop:(UIScreenEdgePanGestureRecognizer *)recognizer {
switch (recognizer.state) {
case UIGestureRecognizerStateBegan:
// Started Dragging
break;

case UIGestureRecognizerStateChanged:
CGFloat percentComplete = [recognizer locationInView:yourView].x / yourView.frame.size.width;
// Do something
break;

case UIGestureRecognizerStateEnded:
// Released
break;

default:
break;
}
}

关于ios - UINavigationControllerDelegate 的方法还不够,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29370539/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com