It’s hard to find the UI code which is not executed in main thread sometimes. You can use the trick below to locate it and fix it.
-
Choose Edit Scheme -> Diagnostics, tick Main Thread Checker.
Xcode 11.4.1
Click the small arrow next to the Main Thread Checker to create a Main Thread Checker breakpoint.
Previous Xcode
-
Run your iOS application to reproduce this issue. (Xcode should pause on the first issue.)
-
Wrap the code that modify the UI in
DispatchQueue.main.async {}