我有一個UITableView
自定義UITableViewCell
在主從結構。表格的單元格可以是文檔或文件夾...如果單元格是文檔,它將在詳細視圖中打開文檔,但如果是文件夾,則會打開下面的其他單元格。 這適用於iOS 7,但在iOS 8中運行時,當我點擊一個單元格,我的應用程序凍結,它需要越來越多的內存......最後它崩潰。 我試過了一切...我搜索了無處不在...似乎沒有任何工作!iOS 8奇怪的問題UITableView
這裏是我的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);
}
通過評論此,應用工程...但細胞不縮進!
當然聽起來像「無限」遞歸給我。找到週期並弄清楚。 – 2014-11-03 12:50:42