崩溃:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread

1.先说一下我的场景吧,在请求麦克风权限的时候,用户点击"是","否",在相应的block里面做处理,调起我的UIView动画,present一个ViewController时,在iPhone7 plus上崩溃,崩溃信息Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread 代码如下:


崩溃:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread_第1张图片
崩溃代码

分析:在if (granted)中,是在子线程中执行的,如果需要在判断语句里面调用界面操作,需要修改如下:


崩溃:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread_第2张图片
修改后的代码

如果需要操作界面的话,需要回到主线程。


你可能感兴趣的:(崩溃:Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'accessing _cachedSystemAnimationFence requires the main thread)