swift 不同tabbar 切换
作者:
目染江夏 | 来源:发表于
2021-11-12 14:14 被阅读0次 let target = self.navigationController?.viewControllers.first(where: { $0.isKind(of: MineViewController.self) })
guard let targetViewController = target as? MineViewController else {
navigationController?.pushViewController(MineViewController(), animated: true)
return
}
// 如果targetViewController是当前mine控制器,否则跳转新页面
if targetViewController.userId == targetUser.userId {
navigationController?.popToViewController(targetViewController, animated: true)
} else { // 跳转到 新的mine控制器
navigationController?.popToRootViewController(animated: false)
let rootAppDelegate = UIApplication.shared.delegate as! AppDelegate
let tabBarController = rootAppDelegate.window?.rootViewController as? BaseTabBarController
let navController = tabBarController?.viewControllers?[0] as? UINavigationController
navController?.pushViewController(MineViewController(), animated: true)
tabBarController?.selectedIndex = 0
}
本文标题:swift 不同tabbar 切换
本文链接:https://www.haomeiwen.com/subject/mrqozltx.html
网友评论