cdts/xdts-ios 3/TreeHole/CYHResetCode/CYH/QMUIKit/UIKitExtensions/UINavigationController+QMUI.h

111 lines
7.5 KiB
C
Raw Permalink Normal View History

2023-07-27 09:20:00 +08:00
/**
* Tencent is pleased to support the open source community by making QMUI_iOS available.
* Copyright (C) 2016-2021 THL A29 Limited, a Tencent company. All rights reserved.
* Licensed under the MIT License (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
* http://opensource.org/licenses/MIT
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
*/
//
// UINavigationController+QMUI.h
// qmui
//
// Created by QMUI Team on 16/1/12.
//
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
NS_ASSUME_NONNULL_BEGIN
typedef NS_ENUM(NSUInteger, QMUINavigationAction) {
QMUINavigationActionUnknow, // 初始、各种动作的 completed 之后都会立即转入 unknown 状态,此时的 appearing、disappearingViewController 均为 nil
QMUINavigationActionWillPush, // push 方法被触发,但尚未进行真正的 push 动作
QMUINavigationActionDidPush, // 系统的 push 已经执行完viewControllers 已被刷新
QMUINavigationActionPushCompleted, // push 动画结束(如果没有动画,则在 did push 后立即进入 completed
QMUINavigationActionWillPop, // pop 方法被触发,但尚未进行真正的 pop 动作
QMUINavigationActionDidPop, // 系统的 pop 已经执行完viewControllers 已被刷新(注意可能有 pop 失败的情况)
QMUINavigationActionPopCompleted, // pop 动画结束(如果没有动画,则在 did pop 后立即进入 completed
QMUINavigationActionWillSet, // setViewControllers 方法被触发,但尚未进行真正的 set 动作
QMUINavigationActionDidSet, // 系统的 setViewControllers 已经执行完viewControllers 已被刷新
QMUINavigationActionSetCompleted, // setViewControllers 动画结束(如果没有动画,则在 did set 后立即进入 completed
};
typedef void (^QMUINavigationActionDidChangeBlock)(QMUINavigationAction action, BOOL animated, __kindof UINavigationController * _Nullable weakNavigationController, __kindof UIViewController * _Nullable appearingViewController, NSArray<__kindof UIViewController *> * _Nullable disappearingViewControllers);
@interface UINavigationController (QMUI) <UIGestureRecognizerDelegate>
/**
NS_DESIGNATED_INITIALIZER init
UINavigationController NS_DESIGNATED_INITIALIZER 4 iOS 12 initWithNavigationBarClass:toolbarClass:initWithRootViewController: 2 NS_DESIGNATED_INITIALIZER initWithNibName:bundle: iOS 13 NS_DESIGNATED_INITIALIZER
iOS init QMUI
*/
- (void)qmui_didInitialize NS_REQUIRES_SUPER;
@property(nonatomic, assign, readonly) QMUINavigationAction qmui_navigationAction;
/**
block UINavigationController push/pop/setViewControllers
block appearingViewController
disappearingViewControllers pop popToRootViewControllersetViewControllers disappearingViewControllers.lastObject pop pop will disappearingViewControllers
weakNavigationController 便 self self retain block block self retain self
@note QMUINavigationAction block block action block action
*/
- (void)qmui_addNavigationActionDidChangeBlock:(QMUINavigationActionDidChangeBlock)block;
/// 是否在 push 的过程中
@property(nonatomic, readonly) BOOL qmui_isPushing;
/// 是否在 pop 的过程中,包括手势、以及代码触发的 pop
@property(nonatomic, readonly) BOOL qmui_isPopping;
/// 获取顶部的 ViewController相比于系统的方法这个方法能获取到 pop 的转场过程中顶部还没有完全消失的 ViewController (请注意:这种情况下,获取到的 topViewController 已经不在栈内)
@property(nullable, nonatomic, readonly) UIViewController *qmui_topViewController;
/// 获取<b>rootViewController</b>
@property(nullable, nonatomic, readonly) UIViewController *qmui_rootViewController;
/// QMUI 会修改 UINavigationController.interactivePopGestureRecognizer.delegate 的值,因此提供一个属性用于获取系统原始的值
@property(nullable, nonatomic, weak, readonly) id<UIGestureRecognizerDelegate> qmui_interactivePopGestureRecognizerDelegate;
- (void)qmui_pushViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^_Nullable)(void))completion;
- (UIViewController *)qmui_popViewControllerAnimated:(BOOL)animated completion:(void (^_Nullable)(void))completion;
- (NSArray<UIViewController *> *)qmui_popToViewController:(UIViewController *)viewController animated:(BOOL)animated completion:(void (^_Nullable)(void))completion;
- (NSArray<UIViewController *> *)qmui_popToRootViewControllerAnimated:(BOOL)animated completion:(void (^_Nullable)(void))completion;
@end
/**
*
*
*/
@protocol UINavigationControllerBackButtonHandlerProtocol <NSObject>
@optional
/**
* pop排除
* 使 Alert NO 退
*/
- (BOOL)shouldPopViewControllerByBackButtonOrPopGesture:(BOOL)byPopGesture;
/// 当自定义了`leftBarButtonItem`按钮之后,系统的手势返回就失效了。可以通过`forceEnableInteractivePopGestureRecognizer`来决定要不要把那个手势返回强制加回来。当 interactivePopGestureRecognizer.enabled = NO 或者当前`UINavigationController`堆栈的viewControllers小于2的时候此方法无效。
- (BOOL)forceEnableInteractivePopGestureRecognizer;
@end
/**
* @see UINavigationControllerBackButtonHandlerProtocol
*/
@interface UIViewController (BackBarButtonSupport) <UINavigationControllerBackButtonHandlerProtocol>
@end
NS_ASSUME_NONNULL_END