ios - iPhone 应用程序在选择 TableViewCell 时卡住 - 间歇性地,暂停/中断后

标签 ios iphone tableviewcell

过去两周我一直在为这个问题苦苦挣扎——在搜索我的代码或堆栈溢出后无法找到解决方案。

问题:

我有一个带有 tableView 和单元格的 View Controller 。大多数时候,当我单击其中一个单元格将我推送到另一个 View Controller 时,它工作正常。然而,有时当我点击一个单元格时,应用程序会卡住。它不会崩溃 - 只是卡住。然后我通常必须按下主页按钮,再次启动应用程序——此时启动会永远持续下去,导致应用程序崩溃。然后我再次启动该应用程序,它会正常返回到我的应用程序的第一页。

我发现它很难复制 - 在正常启动和使用时效果很好。这似乎通常发生在我将应用程序置于后台一段时间或设备已锁定时。不完全确定这会如何影响事情,除了内存清理所需的变量。

请注意,我使用 PrettyKit 库,所以我的单元格是 PrettyTableViewCells。

崩溃报告:

Incident Identifier: A58F4152-0593-481D-8269-1A8115739349
CrashReporter Key:   2dc2c9f2bdbc6370165a53719bc7610fcbe36ddd
Hardware Model:      iPhone4,1
Process:         Yoga [50409]
Path:            /var/mobile/Applications/DEE2950F-4629-43D4-BA6E-349E4119094F/Yoga.app/Yoga
Identifier:      Yoga
Version:         ??? (???)
Code Type:       ARM (Native)
Parent Process:  launchd [1]

Date/Time:       2013-04-23 10:41:02.152 +1000
OS Version:      iOS 6.1.3 (10B329)
Report Version:  104

Exception Type:  00000020
Exception Codes: 0x000000008badf00d
Highlighted Thread:  0

Application Specific Information:
Yoga [50409] has active assertions beyond permitted time: 
{(
    <BKProcessAssertion: 0x1f590b90> identifier: Suspending process: Yoga[50409] permittedBackgroundDuration: 10.000000 reason: suspend owner pid:26 preventSuspend  preventThrottleDownCPU  preventThrottleDownUI 
)}

Elapsed total CPU time (seconds): 8.260 (user 8.260, system 0.000), 67% CPU 
Elapsed application CPU time (seconds): 5.953, 49% CPU

Thread 0 name:  Dispatch queue: com.apple.main-thread
Thread 0:
0   CoreFoundation                  0x313a21fa -[__NSSetM addObject:] + 326
1   Foundation                      0x31dfd1f8 __44-[NSISEngine fixupIntegralizationViolations]_block_invoke_0 + 868
2   Foundation                      0x31dfe9a4 -[NSISEngine withoutOptimizingAtEndRunBlockWithAutomaticOptimizationDisabled:] + 104
3   Foundation                      0x31dfce8a -[NSISEngine fixupIntegralizationViolations] + 90
4   Foundation                      0x31dfe766 -[NSISEngine optimize] + 74
5   Foundation                      0x31dffc4e -[NSISEngine constraintDidChangeSuchThatMarker:shouldBeReplacedByMarkerPlusDelta:] + 82
6   Foundation                      0x31dffcc8 -[NSISEngine tryToChangeConstraintSuchThatMarker:isReplacedByMarkerPlusDelta:undoHandler:] + 56
7   Foundation                      0x31e0564e -[NSLayoutConstraint _tryToChangeContainerGeometryWithUndoHandler:] + 266
8   Foundation                      0x31e059d6 -[NSLayoutConstraint _setSymbolicConstant:constant:] + 382
9   UIKit                           0x3368e14a -[UIView(UIConstraintBasedLayout) _autoresizingConstraints_frameDidChange] + 342
10  UIKit                           0x33253c32 -[UIView(Geometry) setFrame:] + 558
11  UIKit                           0x3329ec4c -[UITableViewCellContentView setFrame:] + 48
12  Foundation                      0x31d03ff2 _NSSetRectValueAndNotify + 106
13  UIKit                           0x332a18cc -[UITableViewCellLayoutManager layoutSubviewsOfCell:] + 2188
14  UIKit                           0x332a0968 -[UITableViewCell layoutSubviews] + 56
15  UIKit                           0x332557fe -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 254
16  QuartzCore                      0x32fffd86 -[CALayer layoutSublayers] + 210
17  QuartzCore                      0x32fff924 CA::Layer::layout_if_needed(CA::Transaction*) + 456
18  QuartzCore                      0x33000858 CA::Layer::layout_and_display_if_needed(CA::Transaction*) + 12
19  QuartzCore                      0x3300023e CA::Context::commit_transaction(CA::Transaction*) + 234
20  QuartzCore                      0x3300004c CA::Transaction::commit() + 312
21  QuartzCore                      0x32fffeac CA::Transaction::observer_callback(__CFRunLoopObserver*, unsigned long, void*) + 56
22  CoreFoundation                  0x3141f6ca __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
23  CoreFoundation                  0x3141d9bc __CFRunLoopDoObservers + 272
24  CoreFoundation                  0x3141dd12 __CFRunLoopRun + 738
25  CoreFoundation                  0x31390eb8 CFRunLoopRunSpecific + 352
26  CoreFoundation                  0x31390d44 CFRunLoopRunInMode + 100
27  GraphicsServices                0x34f692e6 GSEventRunModal + 70
28  UIKit                           0x332a62fc UIApplicationMain + 1116
29  Yoga                            0x000af198 0xae000 + 4504
30  libdyld.dylib                   0x395a9b1c start + 0

Thread 1 name:  Dispatch queue: com.apple.libdispatch-manager
Thread 1:
0   libsystem_kernel.dylib          0x39660648 kevent64 + 24
1   libdispatch.dylib               0x39590974 _dispatch_mgr_invoke + 792
2   libdispatch.dylib               0x39590654 _dispatch_mgr_thread$VARIANT$mp + 32

Thread 2 name:  WebThread
Thread 2:
0   libsystem_kernel.dylib          0x396700fc __psynch_mutexwait + 24
1   libsystem_c.dylib               0x395b9124 pthread_mutex_lock + 388
2   WebCore                         0x373a6418 _WebTryThreadLock(bool) + 184
3   WebCore                         0x373a634a WebRunLoopLock(__CFRunLoopObserver*, unsigned long, void*) + 42
4   CoreFoundation                  0x3141f6ca __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 18
5   CoreFoundation                  0x3141d9bc __CFRunLoopDoObservers + 272
6   CoreFoundation                  0x3141dde8 __CFRunLoopRun + 952
7   CoreFoundation                  0x31390eb8 CFRunLoopRunSpecific + 352
8   CoreFoundation                  0x31390d44 CFRunLoopRunInMode + 100
9   WebCore                         0x373a4500 RunWebThread(void*) + 440
10  libsystem_c.dylib               0x395c930e _pthread_start + 306
11  libsystem_c.dylib               0x395c91d4 thread_start + 4

Thread 3 name:  com.apple.NSURLConnectionLoader
Thread 3:
0   libsystem_kernel.dylib          0x3965feb4 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39660048 mach_msg + 36
2   CoreFoundation                  0x3141f040 __CFRunLoopServiceMachPort + 124
3   CoreFoundation                  0x3141dd9e __CFRunLoopRun + 878
4   CoreFoundation                  0x31390eb8 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x31390d44 CFRunLoopRunInMode + 100
6   Foundation                      0x31cdd3d0 +[NSURLConnection(Loader) _resourceLoadLoop:] + 304
7   Foundation                      0x31d60e80 __NSThread__main__ + 968
8   libsystem_c.dylib               0x395c930e _pthread_start + 306
9   libsystem_c.dylib               0x395c91d4 thread_start + 4

Thread 4 name:  com.apple.CFSocket.private
Thread 4:
0   libsystem_kernel.dylib          0x39670594 __select + 20
1   CoreFoundation                  0x314231f2 __CFSocketManager + 674
2   libsystem_c.dylib               0x395c930e _pthread_start + 306
3   libsystem_c.dylib               0x395c91d4 thread_start + 4

Thread 5 name:  JavaScriptCore::BlockFree
Thread 5:
0   libsystem_kernel.dylib          0x3967008c __psynch_cvwait + 24
1   libsystem_c.dylib               0x395c1d2a _pthread_cond_wait + 642
2   libsystem_c.dylib               0x395c1aa0 pthread_cond_timedwait + 40
3   JavaScriptCore                  0x3535fc70 WTF::ThreadCondition::timedWait(WTF::Mutex&, double) + 104
4   JavaScriptCore                  0x35471552 JSC::BlockAllocator::blockFreeingThreadMain() + 78
5   JavaScriptCore                  0x35483fa8 WTF::wtfThreadEntryPoint(void*) + 12
6   libsystem_c.dylib               0x395c930e _pthread_start + 306
7   libsystem_c.dylib               0x395c91d4 thread_start + 4

Thread 6 name:  JavaScriptCore::Marking
Thread 6:
0   libsystem_kernel.dylib          0x3967008c __psynch_cvwait + 24
1   libsystem_c.dylib               0x395c1d2a _pthread_cond_wait + 642
2   libsystem_c.dylib               0x395cbf14 pthread_cond_wait + 36
3   JavaScriptCore                  0x35404f3c JSC::SlotVisitor::drainFromShared(JSC::SlotVisitor::SharedDrainMode) + 144
4   JavaScriptCore                  0x35404e7c JSC::MarkStackThreadSharedData::markingThreadMain() + 140
5   JavaScriptCore                  0x35483fa8 WTF::wtfThreadEntryPoint(void*) + 12
6   libsystem_c.dylib               0x395c930e _pthread_start + 306
7   libsystem_c.dylib               0x395c91d4 thread_start + 4

Thread 7 name:  WebCore: CFNetwork Loader
Thread 7:
0   libsystem_kernel.dylib          0x3965feb4 mach_msg_trap + 20
1   libsystem_kernel.dylib          0x39660048 mach_msg + 36
2   CoreFoundation                  0x3141f040 __CFRunLoopServiceMachPort + 124
3   CoreFoundation                  0x3141dd9e __CFRunLoopRun + 878
4   CoreFoundation                  0x31390eb8 CFRunLoopRunSpecific + 352
5   CoreFoundation                  0x31390d44 CFRunLoopRunInMode + 100
6   WebCore                         0x3743ed02 WebCore::runLoaderThread(void*) + 138
7   JavaScriptCore                  0x35483fa8 WTF::wtfThreadEntryPoint(void*) + 12
8   libsystem_c.dylib               0x395c930e _pthread_start + 306
9   libsystem_c.dylib               0x395c91d4 thread_start + 4

Unknown thread crashed with unknown flavor: 5, state_count: 1

代码:

我已通过日志记录确定代码在卡住之前成功通过了我的 didSelectRowAtIndexPath 和 prepareForSegue 方法。因此我相信它与表格单元格的构造有关?还是我没有解决的内存问题?

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"logPracticeDetails" sender:indexPath];
    [self.tableView deselectRowAtIndexPath:indexPath animated:YES];
}


- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
    NSIndexPath *indexPath = sender;

    if ([segue.identifier isEqualToString:@"logPracticeDetails"])
    {
        YLLogPracticeViewController *controller = segue.destinationViewController;
        controller.logPractice = [self.logEntry.logEntryPractices objectAtIndex:indexPath.row];
    }
}

非常感谢任何帮助。

最佳答案

对于仍然有类似问题的任何人,我发现原因是我项目中的 AutoLayout

我所要做的只是为我的 UIViewController 停用 AutoLayout 并且停止卡住。

关于ios - iPhone 应用程序在选择 TableViewCell 时卡住 - 间歇性地,暂停/中断后,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16191686/

相关文章:

objective-c - iOS 上的 cv::HoughLines 失败并显示 'OpenCV Error: Assertion failed'

iOS Safari 因提交大型帖子数据表单而崩溃

iphone - 为什么每次在 iOS 中滚动时 UITable 行都未选中

ios - ScrollView 中同时居中和滚动的约束

ios - Realm Swift 0.92.3 "Run Script Phase"不工作

iphone - ASIHTTPRequest https 请求 & SSL

ios - iOS > 8 中通过 TabBarVC 的透明 vc

ios - 表格 View 单元格上的步进器(快速)

ios - 当我用颜色部分填充 TableView 单元格时单元格中的文本出现问题

ios - 指定表格 View 的分隔线宽度