报告UITableview reloadData崩溃 [英] Reporting crash on UITableview reloadData
问题描述
我从Crashlytics获得崩溃报告,该报告始终位于同一位置,但是我无法复制崩溃。
似乎只有iOS 9的用户,而且只是偶尔。我不确定这是代码问题还是其他原因。最后一行提到 libdispatch.dylib
丢失了,再次不确定是否相关。
Crashlytics指出崩溃发生在 MMDetailTableVC.m
行1407,这是 reloadData
行。
以下是报告的内容:
崩溃:com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000001
线程:崩溃:com.apple.main.thread
0 libobjc.A.dylib 0x20f0fae2 objc_msgSend + 1
1 CoreFoundation 0x2168b91b-[NSDictionary descriptionWithLocale:indent:] + 310
2基金会0x21e77e2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x217091a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x21707255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x2171F2_96 118
7 Foundation 0x21f3f4f7 _NSLogv + 126
8 Foundation 0x21e8679d NSLog + 28
9 UIKit 0x259b45fb-[UITableView reloadData] + 1818
10个简单会议纪要0x91fff-[MMDetailTableVC saveItemEntry:](MMDetailTableVC.m: 1407)
11个简单会议纪要0xa2edf-[MMItemViewController saveButtonAction:](MMItemViewController.m:526)
12 UIKit 0x25905771-[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x25a86c71-[UIBarButtonItem(UIInternal)_sendAction:withEvent:] + 140
14 UIKit 0x25905771-[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x25905701-[UIControl sendAction:to: forEvent:] + 64
16 UIKit 0x258ed61f-[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x258ed74b-[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x25905051-[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x25904cbf-[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x258fd5d7-[UIWindow sendEvent:] + 642
21 UIKit 0x258ce119-[ UIApplication sendEvent:] + 204
22 UIKit 0x258cc757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x216f9257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x216f8e47 $ __ $ LRun 70 454 26 CoreFoundation 0x21649bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x216499ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x228c3af9 GSEventRunModal + 160
29 UIKit 0x25935fb5 UIApplicationMain + 144
main 30分钟会议主体0x8 :16)
31 libdispatch.dylib 0x212fc873(丢失)
这是我的 saveItemEntry $ c $的代码c>似乎总是崩溃发生的地方。
-(void)saveItemEntry:(MMitem *)item {
if(item)
{
NSString * resultStr = [self.meetingModel saveItem:item];
if([resultStr isEqualToString:@ OK])
{
//都很好,如此接近表单并刷新数据
[_itemViewController dismissViewControllerAnimated:没有完成:零];
[self.tableView reloadData];
//或者如果有错误结果,则显示消息
}
否则,如果([resultStr isEqualToString:@ DescriptionNotesMissing])
{
[self showAlert:@缺少描述或注释:@需要项目描述或注释:0];
[self.itemViewController.itemDescription成为FirstResponder];
}
//对于任何其他错误,什么都不做
}
}
万岁-终于找到了这个难以解决的问题的原因。崩溃是由于 reloadData
时用户处于表单元格中的 UITextfield
中处于编辑模式而导致的被调用(由于用户点击其他位置或旋转iPad,也称为 ReloadData
)。
我通过在 [self.tableView ReloadData]
和 [self.view endEditing:YES]
之前添加任何内容来解决此问题确保已关闭键盘,并且单元格未处于编辑模式。
这是有道理的,但它是一个讨厌的陷阱。
I'm getting a crash report from Crashlytics that is always in the same place but I'm unable to replicate the crash.
It seems to be only users on iOS 9 and only very occasionally. I'm not sure if it's a code issue or something else. The last line mentions libdispatch.dylib
as being missing, again, not sure if relevant.
Crashlytics indicates that the crash occurs at MMDetailTableVC.m
line 1407, which is the reloadData
line.
Here's what is reported:
Crashed: com.apple.main-thread
EXC_BAD_ACCESS KERN_INVALID_ADDRESS 0x0000000000000001
Thread : Crashed: com.apple.main-thread
0 libobjc.A.dylib 0x20f0fae2 objc_msgSend + 1
1 CoreFoundation 0x2168b91b -[NSDictionary descriptionWithLocale:indent:] + 310
2 Foundation 0x21e77e2d _NSDescriptionWithLocaleFunc + 60
3 CoreFoundation 0x217091a3 __CFStringAppendFormatCore + 7986
4 CoreFoundation 0x21707255 _CFStringCreateWithFormatAndArgumentsAux2 + 80
5 CoreFoundation 0x2171f559 _CFLogvEx2 + 96
6 CoreFoundation 0x2171f9af _CFLogvEx3 + 118
7 Foundation 0x21f3f4f7 _NSLogv + 126
8 Foundation 0x21e8679d NSLog + 28
9 UIKit 0x259b45fb -[UITableView reloadData] + 1818
10 Simple Meeting Minutes 0x91fff -[MMDetailTableVC saveItemEntry:] (MMDetailTableVC.m:1407)
11 Simple Meeting Minutes 0xa2edf -[MMItemViewController saveButtonAction:] (MMItemViewController.m:526)
12 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
13 UIKit 0x25a86c71 -[UIBarButtonItem(UIInternal) _sendAction:withEvent:] + 140
14 UIKit 0x25905771 -[UIApplication sendAction:to:from:forEvent:] + 80
15 UIKit 0x25905701 -[UIControl sendAction:to:forEvent:] + 64
16 UIKit 0x258ed61f -[UIControl _sendActionsForEvents:withEvent:] + 446
17 UIKit 0x258ed74b -[UIControl _sendActionsForEvents:withEvent:] + 746
18 UIKit 0x25905051 -[UIControl touchesEnded:withEvent:] + 616
19 UIKit 0x25904cbf -[UIWindow _sendTouchesForEvent:] + 646
20 UIKit 0x258fd5d7 -[UIWindow sendEvent:] + 642
21 UIKit 0x258ce119 -[UIApplication sendEvent:] + 204
22 UIKit 0x258cc757 _UIApplicationHandleEventQueue + 5134
23 CoreFoundation 0x216f9257 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__ + 14
24 CoreFoundation 0x216f8e47 __CFRunLoopDoSources0 + 454
25 CoreFoundation 0x216f71af __CFRunLoopRun + 806
26 CoreFoundation 0x21649bb9 CFRunLoopRunSpecific + 516
27 CoreFoundation 0x216499ad CFRunLoopRunInMode + 108
28 GraphicsServices 0x228c3af9 GSEventRunModal + 160
29 UIKit 0x25935fb5 UIApplicationMain + 144
30 Simple Meeting Minutes 0x8c59f main (main.m:16)
31 libdispatch.dylib 0x212fc873 (Missing)
And here's my code for saveItemEntry
that always seems to be the place where the crash occurs.
- (void)saveItemEntry:(MMitem *)item{
if (item)
{
NSString *resultStr = [self.meetingModel saveItem:item];
if ([resultStr isEqualToString:@"OK"])
{
// all good so close form and refresh data
[_itemViewController dismissViewControllerAnimated:NO completion:nil];
[self.tableView reloadData];
// or if there is an error result then display message
}
else if ([resultStr isEqualToString:@"DescriptionNotesMissing"])
{
[self showAlert:@"Missing Description or Notes" :@"An Item Description or Notes is required" :0];
[self.itemViewController.itemDescription becomeFirstResponder];
}
// for any other error do nothing
}
}
Hooray - finally found the reason for this elusive problem. The crash was being due to the user being in edit mode within a UITextfield
within a cell in the table when the reloadData
was being called (as a result of the user tapping elsewhere or rotating the iPad, which also called ReloadData
).
I fixed the issue by preceeding any [self.tableView ReloadData]
with [self.view endEditing:YES]
to ensure that the keyboard was dismissed and cells were not in an edit mode.
Does make sense but what a nasty trap.
这篇关于报告UITableview reloadData崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!