用队列+信号量实现了:
一次添加多个控制器,然后present第一个控制器,调用dismiss后自动present第二个控制器,依次进行。。。
支持:
1.连续添加(每次一组或一个控制器)
2.每个控制器都可以添加:
“弹出后回调”(PresentCompletion):通过添加单个控制器的API传入
“关闭后回调”(DismissCompletion):dismiss时,使用系统自带的Completion即可
具体demo看:
https://github.com/iosLiuPeng/MJViewControllerQueue.git
效果图:
API:
@interface UIViewController (Queue)
/// 添加一组控制器(按数组顺序弹出)
+ (void)addViewControlerArrayForName:(NSArray <NSString *>*)arrVC;
/// 添加一组控制器(按数组顺序弹出)
+ (void)addViewControlerArray:(NSArray <UIViewController *> *)arrVC;
/**
添加控制器
@param vcName 控制器名称
@param completion present后回调
*/
+ (void)addViewControllerForName:(NSString *)vcName withPresentCompletion:(void (^ __nullable)(void))completion;
/**
添加控制器
@param vc 控制器
@param completion present后回调
*/
+ (void)addViewController:(UIViewController *)vc withPresentCompletion:(void (^ __nullable)(void))completion;
/// 开始 (如果队列中有之前的任务,请先移除)
+ (void)activeQueue;
/// 移除队列中任务 (只有移除了之前的任务,才能新增任务)
+ (void)removeQueue;
@en
网友评论