ios – performSegueWithIdentifier需要一分钟才能执行或崩溃

ios – performSegueWithIdentifier需要一分钟才能执行或崩溃,第1张

概述在 Xcode 5.0.2中,我创建了一个带有导航控制器的简单iPhone应用程序(源代码可用 at GitHub),导航控制器首先显示带有 Facebook oAuth dialog的Web视图,并且 – 一旦用户进行了身份验证并且已经获取了她的详细信息 – 尝试推送DetailViewController: 在上面的故事板中,我调用了segue segue并通过以下代码将其推送到ViewCon 在 Xcode 5.0.2中,我创建了一个带有导航控制器的简单iPhone应用程序(源代码可用 at GitHub),导航控制器首先显示带有 Facebook oAuth dialog的Web视图,并且 – 一旦用户进行了身份验证并且已经获取了她的详细信息 – 尝试推送DetailVIEwController:

在上面的故事板中,我调用了segue segue并通过以下代码将其推送到ViewController.m:

[self performSegueWithIDentifIEr: @"segue" sender: self];NSLog(@"ID: %@",dict[@"ID"]);NSLog(@"first_name: %@",dict[@"first_name"]);NSLog(@"last_name: %@",dict[@"last_name"]);NSLog(@"gender: %@",dict[@"gender"]);NSLog(@"city: %@",dict[@"location"][@"name"]);

Facebook用户数据很好,几乎立即打印:

ID: 597287941first_name: Alexanderlast_name: Farbergender: malecity: Bochum,Germany

但是在segue发生之前大约一分钟过去了,或者有时应用程序甚至崩溃

2014-01-09 22:11:29.017 oauthFacebook[4012:1403] *** Terminating app due to uncaught exception 'NSUnkNownKeyException',reason: '[<DetailVIEwController 0x8a89cd0> setValue:forUndefinedKey:]: this class is not key value Coding-compliant for the key ID.'*** First throw call stack:(    0   CoreFoundation                      0x0173b5e4 __exceptionPreprocess + 180    1   libobjc.A.dylib                     0x014be8b6 objc_exception_throw + 44    2   CoreFoundation                      0x017cb6a1 -[NSException raise] + 17    3   Foundation                          0x0117f9ee -[NSObject(NSkeyvalueCoding) setValue:forUndefinedKey:] + 282    4   Foundation                          0x010ebcfb _NSSetUsingkeyvalueSetter + 88    5   Foundation                          0x010eb253 -[NSObject(NSkeyvalueCoding) setValue:forKey:] + 267    6   Foundation                          0x0114d70a -[NSObject(NSkeyvalueCoding) setValue:forKeyPath:] + 412    7   UIKit                               0x004cea15 -[UIRuntimeOutletConnection connect] + 106    8   libobjc.A.dylib                     0x014d07d2 -[NSObject performSelector:] + 62    9   CoreFoundation                      0x01736b6a -[NSArray makeObjectsPerformSelector:] + 314    10  UIKit                               0x004cd56e -[UINib instantiateWithOwner:options:] + 1417    11  UIKit                               0x0033f605 -[UIVIEwController _loadVIEwFromNibnamed:bundle:] + 280    12  UIKit                               0x0033fdad -[UIVIEwController loadVIEw] + 302    13  UIKit                               0x003400ae -[UIVIEwController loadVIEwIfrequired] + 78    14  UIKit                               0x003405b4 -[UIVIEwController vIEw] + 35    15  UIKit                               0x0035a3e2 -[UINavigationController _startCustomTransition:] + 778    16  UIKit                               0x003670c7 -[UINavigationController _startDeferredTransitionIfNeeded:] + 688    17  UIKit                               0x00367cb9 -[UINavigationController __vIEwWillLayoutSubvIEws] + 57    18  UIKit                               0x004a1181 -[UILayoutContainerVIEw layoutSubvIEws] + 213    19  UIKit                               0x00297267 -[UIVIEw(CALayerDelegate) layoutSublayersOfLayer:] + 355    20  libobjc.A.dylib                     0x014d081f -[NSObject performSelector:withObject:] + 70    21  QuartzCore                          0x03b492ea -[CALayer layoutSublayers] + 148    22  QuartzCore                          0x03b3d0d4 _ZN2CA5Layer16layout_if_neededEPNS_11TransactionE + 380    23  QuartzCore                          0x03b3cf40 _ZN2CA5Layer28layout_and_display_if_neededEPNS_11TransactionE + 26    24  QuartzCore                          0x03aa4ae6 _ZN2CA7Context18commit_transactionEPNS_11TransactionE + 294    25  QuartzCore                          0x03aa5e71 _ZN2CA11Transaction6commitEv + 393    26  QuartzCore                          0x03aa60c2 _ZN2CA11Transaction14release_threadEPv + 226    27  libsystem_pthread.dylib             0x01e7681c _pthread_tsd_cleanup + 93    28  libsystem_pthread.dylib             0x01e7327e _pthread_exit + 108    29  libsystem_pthread.dylib             0x01e73dd8 pthread_workqueue_setdispatchoffset_np + 0    30  libsystem_pthread.dylib             0x01e77cce start_wqthread + 30)libc++abi.dylib: terminating with uncaught exception of type NSException(lldb)

请问这种行为的原因是什么?

更新:

我按照Savana的建议清理了IBOutlets(谢谢),但应用程序仍然崩溃:

2014-01-10 10:26:59.379 oauthFacebook[4342:4113] bool _WebTryThreadLock(bool),0x8be2960: TrIEd to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing Now...1   0x51481ae WebThreadLock2   0x452a57 -[UIWebdocumentVIEw _responderForBecomeFirstResponder]3   0x27da9e -[UIVIEw setUserInteractionEnabled:]4   0x934d72 -[_UIVIEwControllerTransitionContext _disableInteractionForVIEws:]5   0x368573 -[UINavigationController pushVIEwController:Transition:forceImmediate:]6   0x3680b5 -[UINavigationController pushVIEwController:animated:]7   0x770c65 -[UIStoryboardPushSegue perform]8   0x76107e -[UIStoryboardSegueTemplate _perform:]9   0x342280 -[UIVIEwController performSegueWithIDentifIEr:sender:]10  0x29f0 __32-[VIEwController fetchFacebook:]_block_invoke11  0x11da695 __67+[NSURLConnection sendAsynchronousRequest:queue:completionHandler:]_block_invoke_212  0x113a945 -[NSBlockOperation main]13  0x1193829 -[__NSOperationInternal _start:]14  0x1110558 -[NSOperation start]15  0x1195af4 __NSOQSchedule_f16  0x1ae74b0 _dispatch_clIEnt_callout17  0x1ad4018 _dispatch_async_redirect_invoke18  0x1ae74b0 _dispatch_clIEnt_callout19  0x1ad5eeb _dispatch_root_queue_drain20  0x1ad6137 _dispatch_worker_thread221  0x1e73dab _pthread_wqthread22  0x1e77cce start_wqthread(lldb)

而且当我添加一个断言([NSThread isMainThread]);在performSegueWithIDentifIEr调用之前,我可以看到这不是主线程…

在主线程上是否需要调用performSegueWithIDentifIEr?

解决方法 我已经能够使用以下代码解决我的问题(详细视图控制器在延迟或应用程序崩溃后显示):

dispatch_async(dispatch_get_main_queue(),^(voID) {             [self performSegueWithIDentifIEr: @"segue" sender: self];         });
总结

以上是内存溢出为你收集整理的ios – performSegueWithIdentifier需要一分钟才能执行或崩溃全部内容,希望文章能够帮你解决ios – performSegueWithIdentifier需要一分钟才能执行或崩溃所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/web/1007045.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-05-22
下一篇 2022-05-22

发表评论

登录后才能评论

评论列表(0条)

保存