0
我試圖修復在我們的任何測試設備上都無法重現的chrash。該應用程序崩潰無數次(60K次),因爲這些正在報道crashlytics。在crashlytics中,同樣的崩潰報告有所不同。但我認爲兩者都是一樣的。加載或重新加載時,應用程序在用戶設備上崩潰uitableview
崩潰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];
}
我很少有其他地方的我正在插入&刪除的東西。任何人都可以在我的編輯中看到錯誤。
請看我的編輯 – Rajashekar 2015-04-03 14:19:04
@Rajashekar我希望你不要因此而感到沮喪。但是人們很難在你的邏輯中看到錯誤。每次刪除/更新後,確保您的numberOfRowsInSection也會返回正確的值。 在您的代碼中添加斷點並確保值正確與否。 – 2015-04-03 14:20:45