How to Wait in Objective-C and Swift

后端 未结 8 809
自闭症患者
自闭症患者 2021-01-31 02:22

I want to change my UILabel\'s text after 2 seconds.

I tried setting my UILabel\'s text to \"A text\", and use sleep(2) a

8条回答
  •  梦如初夏
    2021-01-31 02:50

    This is because the view isn't updated until the end of the runloop. Instead of using sleeps try using NSTimer to set a specific time to update the view.

提交回复
热议问题