How can I delay a method call for 1 second?

前端 未结 11 1389
别跟我提以往
别跟我提以往 2020-11-30 18:19

Is there an easy way delay a method call for 1 second?

I have a UIImageView that reacts on a touch event. When the touch is detected, some animations ha

11条回答
  •  半阙折子戏
    2020-11-30 18:58

    NOTE: this will pause your whole thread, not just the one method.
    Make a call to sleep/wait/halt for 1000 ms just before calling your method?

    Sleep(1000); // does nothing the next 1000 mSek
    
    Methodcall(params); // now do the real thing
    

    Edit: The above answer applies to the general question "How can I delay a method call for 1 second?", which was the question asked at the time of the answer (infact the answer was given within 7 minutes of the original question :-)). No Info was given about the language at that time, so kindly stop bitching about the proper way of using sleep i XCode og the lack of classes...

提交回复
热议问题