“仅在主线程上运行”例外是仅模拟器

波阿斯

我在内部深处(或之后)出现“仅在主线程上运行”异常

[self.navigationController pushViewController:controller animated:YES];

问题是它仅在模拟器上发生,而不是在IOS设备上调试时发生。
有机会我可以解决这个问题吗?

转储:

2014-03-25 15:18:45.061 Cookila[657:5507] *** Assertion failure in void _UIPerformResizeOfTextViewForTextContainer(NSLayoutManager *, UIView<NSTextContainerView> *, NSTextContainer *, NSUInteger)(), /SourceCache/UIFoundation_Sim/UIFoundation-264.8/UIFoundation/TextSystem/NSLayoutManager_Private.m:1510
2014-03-25 15:18:45.086 Cookila[657:5507] *** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Only run on the main thread!'
*** First throw call stack:
(
    0   CoreFoundation                      0x027251e4 __exceptionPreprocess + 180
    1   libobjc.A.dylib                     0x024a48e5 objc_exception_throw + 44
    2   CoreFoundation                      0x02725048 +[NSException raise:format:arguments:] + 136
    3   Foundation                          0x01f43b20 -[NSAssertionHandler handleFailureInFunction:file:lineNumber:description:] + 101
    4   UIFoundation                        0x0947fe25 -[NSLayoutManager(NSPrivate) _resizeTextViewForTextContainer:] + 419
    5   UIFoundation                        0x0947fb0a -[NSLayoutManager(NSPrivate) _recalculateUsageForTextContainerAtIndex:] + 2083
    6   UIFoundation                        0x094b4289 _enableTextViewResizing + 234
    7   UIFoundation                        0x094b7e89 -[NSLayoutManager textStorage:edited:range:changeInLength:invalidatedRange:] + 688
    8   UIFoundation                        0x094b7f0e -[NSLayoutManager processEditingForTextStorage:edited:range:changeInLength:invalidatedRange:] + 82
    9   UIFoundation                        0x094e0ab5 -[NSTextStorage _notifyEdited:range:changeInLength:invalidatedRange:] + 153
    10  UIFoundation                        0x094e05f0 -[NSTextStorage processEditing] + 462
    11  UIFoundation                        0x094e0199 -[NSTextStorage endEditing] + 80
    12  UIFoundation                        0x094e0223 -[NSTextStorage coordinateEditing:] + 66
    13  UIKit                               0x016618cb -[UITextView setAttributedText:] + 254
    14  UIKit                               0x01660c16 -[UITextView initWithCoder:] + 706
    15  UIKit                               0x01372d6d UINibDecoderDecodeObjectForValue + 704
    16  UIKit                               0x01372f6e UINibDecoderDecodeObjectForValue + 1217
    17  UIKit                               0x01372aa1 -[UINibDecoder decodeObjectForKey:] + 114
    18  UIKit                               0x00faafa4 -[UIView initWithCoder:] + 842
    19  UIKit                               0x01372d6d UINibDecoderDecodeObjectForValue + 704
    20  UIKit                               0x01372f6e UINibDecoderDecodeObjectForValue + 1217
    21  UIKit                               0x01372aa1 -[UINibDecoder decodeObjectForKey:] + 114
    22  UIKit                               0x00faafa4 -[UIView initWithCoder:] + 842
    23  UIKit                               0x00fcdff1 -[UIScrollView initWithCoder:] + 58
    24  UIKit                               0x01372d6d UINibDecoderDecodeObjectForValue + 704
    25  UIKit                               0x01372aa1 -[UINibDecoder decodeObjectForKey:] + 114
    26  UIKit                               0x0120d7a7 -[UIRuntimeConnection initWithCoder:] + 191
    27  UIKit                               0x01372d6d UINibDecoderDecodeObjectForValue + 704
    28  UIKit                               0x01372f6e UINibDecoderDecodeObjectForValue + 1217
    29  UIKit                               0x01372aa1 -[UINibDecoder decodeObjectForKey:] + 114
    30  UIKit                               0x0120cc21 -[UINib instantiateWithOwner:options:] + 1117
    31  UIKit                               0x010756f5 -[UIViewController _loadViewFromNibNamed:bundle:] + 280
    32  UIKit                               0x01075e9d -[UIViewController loadView] + 302
    33  UIKit                               0x010760d3 -[UIViewController loadViewIfRequired] + 78
    34  UIKit                               0x010765d9 -[UIViewController view] + 35
    35  UIKit                               0x01090942 -[UINavigationController _startCustomTransition:] + 778
    36  UIKit                               0x0109d8f7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688
    37  UIKit                               0x0109e4e9 -[UINavigationController __viewWillLayoutSubviews] + 57
    38  UIKit                               0x011df0d1 -[UILayoutContainerView layoutSubviews] + 213
    39  UIKit                               0x00fc6964 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 355
    40  libobjc.A.dylib                     0x024b682b -[NSObject performSelector:withObject:] + 70
    41  QuartzCore                          0x00e2e45a -[CALayer layoutSublayers] + 148
    42  QuartzCore                          0x00e22244 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380
    43  QuartzCore                          0x00e220b0 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26
    44  QuartzCore                          0x00d887fa _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294
    45  QuartzCore                          0x00d89b85 _ZN2CA11Transaction6commitEv + 393
    46  QuartzCore                          0x00d89dd6 _ZN2CA11Transaction14release_threadEPv + 226
    47  libsystem_pthread.dylib             0x031f581c _pthread_tsd_cleanup + 93
    48  libsystem_pthread.dylib             0x031f227e _pthread_exit + 108
    49  libsystem_pthread.dylib             0x031f21e8 pthread_exit + 33
    50  Foundation                          0x01ef1dd2 __NSFinalizeThreadData + 0
    51  Foundation                          0x01eee97e __NSThread__main__ + 1299
    52  libsystem_pthread.dylib             0x031f15fb _pthread_body + 144
    53  libsystem_pthread.dylib             0x031f1485 _pthread_struct_init + 0
    54  libsystem_pthread.dylib             0x031f6cf2 thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException
托马斯·库勒斯

请从主线程执行UI回调。绝不能从后台线程更新UI。

使用Grand Central Dispatch进行UI更新吗:

dispatch_async(dispatch_get_main_queue(), ^{
    /* Your UI code */
});

本文收集自互联网,转载请注明来源。

如有侵权,请联系[email protected] 删除。

编辑于
0

我来说两句

0条评论
登录后参与评论

相关文章

来自分类Dev

仅在真实设备上无法在模拟器上运行Xcode项目

来自分类Dev

'NSInternalInconsistencyException',原因:“仅在主线程上运行!” 错误

来自分类Dev

在iOS模拟器上运行Safari

来自分类Dev

在iOs模拟器上运行DalekJS

来自分类Dev

在Mac上运行android模拟器

来自分类Dev

单击Android Spinner仅在模拟器上引发NullPointerException

来自分类Dev

ld:找不到库(仅在模拟器上)

来自分类Dev

Admobs广告仅在模拟器上展示

来自分类Dev

哪些代码将在浏览器的主线程上运行?

来自分类Dev

在主线程上运行代码?

来自分类Dev

在主线程上运行代码?

来自分类Dev

Android在设备上运行,但在模拟器上崩溃

来自分类Dev

Youtube在设备上失败,可在模拟器上运行

来自分类Dev

addSubview在设备上运行,在模拟器上崩溃

来自分类Dev

Youtube在设备上失败,可在模拟器上运行

来自分类Dev

Volley 在模拟器上运行但在设备上失败

来自分类Dev

AdView在模拟器上仅显示测试横幅

来自分类Dev

在真实设备上运行模拟器与模拟器

来自分类Dev

无法在模拟器上运行Android App

来自分类Dev

在Mac上运行Blackberry 10模拟器

来自分类Dev

使用xcodebuild在模拟器上构建和运行应用

来自分类Dev

不能在模拟器上运行的功能(iOS开发)

来自分类Dev

如何在模拟器上运行UIAutomator?

来自分类Dev

波纹模拟器无法在Max OSX上运行

来自分类Dev

在模拟器上运行Google Play服务5.0.89

来自分类Dev

核心位置不在iOS模拟器上运行

来自分类Dev

Android:Google Play服务无法在模拟器上运行

来自分类Dev

无法在Mac的Genymotion模拟器上运行telnet命令

来自分类Dev

在Android模拟器上运行的Ubuntu Touch

Related 相关文章

热门标签

归档