How to do some stuff in viewDidAppear only once?

前端 未结 8 1445
暖寄归人
暖寄归人 2020-11-29 03:25

I want to check the pasteboard and show an alert if it contains specific values when the view appears. I can place the code into viewDidLoad to ensure it\'s onl

8条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-11-29 03:56

    You shouldn't have issues in nested view controllers with this check

    extension UIViewController {
    
      var isPresentingForFirstTime: Bool {
          if let parent = parent {
            return parent.isPresentingForFirstTime
          }
          return isBeingPresented || isMovingFromParent
      }
    }
    

提交回复
热议问题