ios - viewdidappear 未从选项卡栏 Controller 调用

标签 ios swift xcode

我有一个 TabBarControllerNavigationController...主 TabController 有一些我想添加边框的按钮...在 ViewDidAppear 中执行此操作,但未调用!当我转到子 Controller 并单击后退按钮时,它现在被调用..但是当第一次单击该选项卡时,不会调用该选项卡!

我在主选项卡 vc 中正在做什么:

  override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)

    if MOLHLanguage.isArabic(){
        aboutusbtn.addRightBorderHome( borderWidth: 3)
        rulesbtn.addRightBorderAboutus(borderWidth: 3)
        committeebtn.addRightBorderHistory(borderWidth: 3)
        generalbtn.addRightBorderShare(borderWidth: 3)
        publickbtn.addRightBorderHome(borderWidth: 3)
        contactusbtn.addRightBorderAboutus(borderWidth: 3)
    }else{
        aboutusbtn.addLeftBorderHome(width: 3)
        committeebtn.addLeftBorderAboutus(width: 3)
        rulesbtn.addLeftBorderHistory(width: 3)
        generalbtn.addLeftBorderShare(width: 3)
        publickbtn.addLeftBorderHome(width: 3)
        contactusbtn.addLeftBorderAboutus(width: 3)
    }
}

但是直到我从子项中单击返回后才调用此函数...但是当第一次单击选项卡时它不会被调用!

为什么?以及如何解决这个问题?

最佳答案

我找到了解决方案..

我刚刚添加了以下内容:

override func viewDidAppear(_ animated: Bool) {
    super.viewDidAppear(animated)
 }

在导航 Controller 中,问题就解决了! :)

关于ios - viewdidappear 未从选项卡栏 Controller 调用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51648081/

相关文章:

ios - 显示 ScrollView 中的 View 时如何更新? Viewdidload 不工作?

ios - 来自 Objective C 的 Swift 中的完成 block

iphone - 错误 CGImageCreate : invalid image size: 0 x 0 with a (picker) window rotation

iOS/swift : Custom UIGestureRecognizer that detect spin motion

ios - 如何在关闭任务完成后删除监听器?

ios - 我希望打印的值太长,无法打印 firebase 中的所有值

ios - 应用因持久存储创建崩溃而被拒绝

swift - 如何在 Swift 中为 UIViewController 子类创建自定义初始化程序?

iphone - 如何在我的 iPhone 应用程序中包含 512X512 图标?

swift - Xcode 9.0 版自动建议的默认 Swift 版本是什么?