【发布时间】:2015-04-03 13:51:06
【问题描述】:
我正在尝试修复无法在我们的任何测试设备上重现的 chrash。该应用程序崩溃了很多次(60k 次),因为这些都在 crashlytics 上报告。在 crashlytics 中以不同方式报告相同的崩溃。但我认为两者都是一样的。
崩溃 1
崩溃 2
两次崩溃属于同一类型。
我有 2 个不同的委托方法在链上触发。
第一个委托方法有以下代码,该方法由 UITableviewcell 实现。
- (void)flightSegment:(FlightSegmentViewController *)flightSegmentController didChangeHeightWith:(CGFloat)heightDelta {
int index = [flightSegmentControllers indexOfObject:flightSegmentController]; //Shows warning as indexOfObject returns NSUInteger rather than int. Could this be the problem? if it is then it should crash in all the devices.
[UIView beginAnimations:@"originAndDestinationAnimation" context:nil];
[UIView setAnimationDuration:0.3f];
for (int i = index + 1; i < flightSegmentControllers.count; i++) {
FlightSegmentViewController *vc = [flightSegmentControllers objectAtIndex:i];
CGRect frame = vc.view.frame;
frame.origin.y += heightDelta;
vc.view.frame = frame;
}
[UIView commitAnimations];
[delegate bookingCell:self didChangeHeightWith:heightDelta];
}
第二个委托方法有以下代码。这个委托方法是由实际的 TableViewContoller 实现的。
- (void)bookingCell:(XXXGMBookingCell *)theBookingCell didChangeHeightWith:(CGFloat)heightDelta {
[menuTableView beginUpdates];
[menuTableView endUpdates];
[self performSelector:@selector(reloadData) withObject:menuTableView afterDelay:0.333f];
}
有人可以指导这是崩溃的地方吗?我的主要意图是在我的测试设备上重现该问题,然后尝试修复它。
编辑
- (void)disruptionBannerShow {
NSInteger numOfRowsInSectionNul = [self tableView:menuTableView numberOfRowsInSection:0];
if (numOfRowsInSectionNul == 0) {
[menuTableView beginUpdates];
NSArray *insertedRows = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]];
[menuTableView insertRowsAtIndexPaths:insertedRows withRowAnimation:UITableViewRowAnimationTop];
[menuTableView endUpdates];
}
[self performSelector:@selector(reloadData) withObject:menuTableView afterDelay:0.33333f];
}
还有
- (void)disruptionBannerHide {
NSInteger numOfRowsInSectionNul = [self tableView:menuTableView numberOfRowsInSection:0];
if (numOfRowsInSectionNul > 0) {
[menuTableView beginUpdates];
NSArray *deletedRows = [NSArray arrayWithObject:[NSIndexPath indexPathForRow:0 inSection:0]];
[menuTableView deleteRowsAtIndexPaths:deletedRows withRowAnimation:UITableViewRowAnimationTop];
[menuTableView endUpdates];
}
[self performSelector:@selector(reloadData) withObject:menuTableView afterDelay:0.33333f];
}
我几乎没有其他地方可以插入和删除某些东西。任何人都可以在我的编辑中看到错误。
【问题讨论】:
标签: ios uitableview delegates reloaddata