UITableViewCell扩展单元格但切断内容

时间:2014-02-21 00:13:29

标签: ios objective-c uitableview

我有一个表视图,我已经实现了扩展表格单元格。它适用于iPhone上的iOS 6。我正在更新适用于iPad的iOS 7应用程序。同一个表,大多数相同的代码,有一个命中或未命中问题,其中扩展的文本有时被切断 - 有时并不总是被切断,有时,我没有找到一个模式。只要滚动视图甚至1个像素,文本就会显示出来并且视图正确。很明显,这是一种刷新,而不是细胞本身扩张的问题。

我尝试了一些东西来刷新单元格或表格,但这些东西会干扰[beginUpdates / endUpdates]的流畅动画。

table view http://www.paveglio.com/postimages/cdna-row-cutoff-20140220.png

这是我用于扩展单元格的代码块:

- (void)checkButtonTapped:(id)sender event:(id)event
{
    //the toggle button calls this method to toggle row height
    //get the touched/tapped button location and translate it to a row
    NSSet *touches = [event allTouches];
    UITouch *touch = [touches anyObject];
    CGPoint currentTouchPosition = [touch locationInView:self.optionsTable];

    NSIndexPath *indexPath = [self.optionsTable indexPathForRowAtPoint: currentTouchPosition];
    if (indexPath != nil)
    {
        if ([[[OptionCodeStore sharedStore] optionForIndexPath:indexPath] cellHeight] > baseCellHeight) {
            //the cell is already expanded, so toggle back to small size, use default value
            [[[OptionCodeStore sharedStore] optionForIndexPath:indexPath] setCellHeight:baseCellHeight];
            [[[OptionCodeStore sharedStore] optionForIndexPath:indexPath] setCellExpanded:NO];
            [[(OptionCell *)[self.optionsTable cellForRowAtIndexPath:indexPath] optMoreCmtBtn] setImage:[UIImage imageNamed:@"MoreDot.png"] forState:UIControlStateNormal];
        } else {
            //ask the cell at row X to get its expanded size
            float expSize = [(OptionCell *)[self.optionsTable cellForRowAtIndexPath:indexPath] expandedCellHeight];
            //put new size into row heights array
            [[[OptionCodeStore sharedStore] optionForIndexPath:indexPath] setCellHeight:expSize];
            [[[OptionCodeStore sharedStore] optionForIndexPath:indexPath] setCellExpanded:YES];
            [[(OptionCell *)[self.optionsTable cellForRowAtIndexPath:indexPath] optMoreCmtBtn] setImage:[UIImage imageNamed:@"LessDot.png"] forState:UIControlStateNormal];
        }
    }

    //automagically expand/reload rows
    [optionsTable beginUpdates];
//    [optionsTable reloadData]; //reloads full view but makes animation jerky
//    [optionsTable reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation:UITableViewRowAnimationAutomatic]; //still not 100% perfect
    [optionsTable endUpdates];
}

0 个答案:

没有答案