调整逻辑
This commit is contained in:
@@ -78,11 +78,28 @@
|
||||
#pragma mark - Actions
|
||||
|
||||
- (void)onBack {
|
||||
// 先关闭自身,再让调用方按需处理(例如同时退出引导页)
|
||||
void (^handler)(void) = self.onBack;
|
||||
[self dismissViewControllerAnimated:YES completion:^{
|
||||
if (handler) handler();
|
||||
}];
|
||||
// 支持两种展示方式:
|
||||
// 1) 作为子控制器嵌入(无 presentingViewController)→ 交由回调让父 VC 处理(通常 pop)
|
||||
// 2) 作为模态弹出 → 按原策略先 pop 再 dismiss
|
||||
UIViewController *presenter = self.presentingViewController;
|
||||
if (!presenter) {
|
||||
if (self.backHandler) self.backHandler();
|
||||
return;
|
||||
}
|
||||
|
||||
UINavigationController *nav = nil;
|
||||
if ([presenter isKindOfClass:UINavigationController.class]) {
|
||||
nav = (UINavigationController *)presenter;
|
||||
} else if (presenter.navigationController) {
|
||||
nav = presenter.navigationController;
|
||||
}
|
||||
|
||||
if (nav) {
|
||||
[nav popViewControllerAnimated:NO];
|
||||
[nav dismissViewControllerAnimated:YES completion:^{ if (self.backHandler) self.backHandler(); }];
|
||||
} else {
|
||||
[self dismissViewControllerAnimated:YES completion:^{ if (self.backHandler) self.backHandler(); }];
|
||||
}
|
||||
}
|
||||
|
||||
- (void)openSettings {
|
||||
|
||||
Reference in New Issue
Block a user