ios 销毁当前页面重新开启_iOS使用UINavigationController跳转页面怎么销毁当前页面...

其实就是指定跳转位置,略过你栈中的一个或多个控制器。核心方法就是- (nullable UIViewController *)popViewControllerAnimated:(BOOL)animated;,只要在你的navigation.viewControllers中拿到你想要的控制器就可以了。以下代码可以略微参考一下,是自己写的navigation基类,实现点击返回的手动控制及位置指定

// .h

@property (nonatomic, assign) NSInteger targetIndex;

@property (nonatomic, copy) void(^backOperStandBy)(void(^handleBack)(BOOL back,NSInteger targetIndex),NSInteger operIndex);

// .m

- (void)sp_popViewController{

if (self.backOperStandBy != nil) {

__weak typeof(self) ws = self;

self.backOperStandBy(^(BOOL back, NSInteger targetIndex) {

if (back) {

ws.targetIndex = targetIndex;

[ws handlePopAction];

}

}, self.viewControllers.count-1);

} else {

[self handlePopAction];

}

}

- (void)handlePopAction

{

if (self.targetIndex == RootIndex) {

[self popToRootViewControllerAnimated:YES];

return;

}

if (self.targetIndex != 0 && self.targetIndex > 0) {

UIViewController *target = self.viewControllers[self.targetIndex];

self.targetIndex = 0;

if (target) {

[self popToViewController:target animated:YES];

}else{

[self popViewControllerAnimated:YES];

}

return;

}

// 普通情况

[self popViewControllerAnimated:YES];

}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值