How to Wait in Objective-C and Swift

后端 未结 8 825
自闭症患者
自闭症患者 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:35

    You can use

    [self performSelector:@selector(changeText:) withObject:text afterDelay:2.0];
    

    or if you want to display it periodically, check the NSTimer class.

提交回复
热议问题