Creating a method to perform animations and wait for completion using a semaphore in objective c

后端 未结 5 1600
没有蜡笔的小新
没有蜡笔的小新 2020-12-12 01:02

I am trying to create a method which makes use of UIView\'s \"+animateWithDuration:animations:completion\" method to perform animations, and wait for completion. I am well a

5条回答
  •  时光说笑
    2020-12-12 01:10

    You appear to be using a semaphore to block the main thread until animations compete. Unfortunately the main thread is the thread performing those animations so this will never occur.

    You must not block the main thread of your application. By doing so you prevent any view drawing or responding to user input. You will also soon trigger an OS watchdog which detects your app as unresponsive and terminates it.

    Animations an their completion blocks are expressed as asynchronous operations for good reason. Try to embrace that in your design.

提交回复
热议问题