[英]Strange issue in iOS 8 UITableView
我有一個UITableView
,在Master-Detail結構中具有自定義UITableViewCell
。 表格的單元格可以是文檔或文件夾...如果一個單元格是一個文檔,它將在詳細信息視圖中打開文檔,但是如果是一個文件夾,則將在下面打開其他單元格。 這在iOS 7上完美運行,但是在iOS 8上運行時,當我點擊一個單元格時,我的應用程序凍結,並且占用了越來越多的內存...最后,它崩潰了。 我已經嘗試了一切...我已經搜索了一切...似乎什么都沒用!
這是我的didSelectRowAtIndexPath:方法
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"OBJECTS: %lu", (unsigned long)_objects.count);
[tableView deselectRowAtIndexPath:indexPath animated:YES];
NSDictionary *d=[_objects objectAtIndex:indexPath.row];
if([d valueForKey:@"Objects"])
{
NSArray *ar=[d valueForKey:@"Objects"];
BOOL isAlreadyInserted=NO;
for(NSDictionary *dInner in ar )
{
NSInteger index=[_objects indexOfObjectIdenticalTo:dInner];
isAlreadyInserted=(index>0 && index!=NSIntegerMax);
if(isAlreadyInserted) break;
}
if(isAlreadyInserted)
{
[self miniMizeThisRows:ar];
}
else
{
NSUInteger count=indexPath.row+1;
NSMutableArray *arCells=[NSMutableArray array];
for(NSDictionary *dInner in ar )
{
[arCells addObject:[NSIndexPath indexPathForRow:count inSection:0]];
[_objects insertObject:dInner atIndex:count++];
}
[self addRowsAtIndexPaths:arCells];
}
}
else
{
NSDictionary *object = [_objects objectAtIndex:indexPath.row];
self.detailViewController.detailItem = [object objectForKey:@"name"];
self.detailViewController.title = [object objectForKey:@"displayedName"];
if(![cache containsObject:object])
{
TableCustomCell *cell = (TableCustomCell*)[tableView cellForRowAtIndexPath:indexPath];
[cell.marker setHidden:NO];
[cache addObject:object];
}
}
}
在addRowsAtIndexPaths中:
- (void)addRowsAtIndexPaths:(NSArray*)indexPaths
{
[self.tableView beginUpdates];
[self.tableView insertRowsAtIndexPaths:indexPaths withRowAnimation:UITableViewRowAnimationMiddle];
[self.tableView endUpdates];
}
有人幫忙???
謝謝。
編輯
我發現循環是由我的UITableViewCell sublcass引起的...我使用以下代碼來管理縮進:
- (void)layoutSubviews
{
[super layoutSubviews];
float indentPoints = self.indentationLevel * self.indentationWidth;
self.contentView.frame = CGRectMake(indentPoints,
self.contentView.frame.origin.y,
self.contentView.frame.size.width - indentPoints,
self.contentView.frame.size.height);
}
通過評論此內容,該應用程序可以正常工作...但是單元格沒有縮進!
在凍結期間,嘗試在調試器上按“暫停”按鈕,然后在callStack上查看,然后按“繼續”按鈕,再按“暫停”,然后查找調用,它們之間是一樣的。 看起來像通話周期。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.