UIView did appear?

后端 未结 5 1743
没有蜡笔的小新
没有蜡笔的小新 2021-02-05 00:25

I\'m wondering, is there a way to get a delegate or something, when a particular UIView has been shown on the screen ?

5条回答
  •  难免孤独
    2021-02-05 01:07

    Swift version. Inside your UIView class just:

    override func willMove(toWindow newWindow: UIWindow?) {
        super.willMove(toWindow: newWindow)
    
        if newWindow == nil {
            // UIView disappear
        } else {
            // UIView appear
        }
    }
    

提交回复
热议问题