在cellForRowAtIndexPath

时间:2015-06-18 01:20:10

标签: ios objective-c uitableview uiview

我有一个自定义的TablViewCell,它是一个自定义单元格(UITableViewAutomaticDimension)。因此,我没有使用heightForRowAtIndexPath。

无论如何,我有一个高1像素的视图,占据了单元格宽度的90%左右。只是一条很长的细线。

我无法获得此线的准确宽度。我按照故事板不断获得线条的宽度,而不是它在设备上的实际尺寸。

我可能通过缓存viewWillAppear中控制器视图的宽度来获取它,然后减去前导/尾随约束来计算宽度,但这太荒谬了。

有谁知道如何在出列后立即获得cellForRowAtIndexPath中单元格的精确帧宽和一般帧大小?

代码:

    static NSString *cellIdentifier = @"PlayerQuestionDetailCell";
    FFFPlayerQuestionDetailTableViewCell *percentageCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier forIndexPath:indexPath];

    [percentageCell updateColors];

    ...


        NSLog(@"Line4: %@", NSStringFromCGRect(percentageCell.lineVertical4.frame));
        NSLog(@"Line3: %@", NSStringFromCGRect(percentageCell.lineVertical3.frame));
        NSLog(@"Top: %@", NSStringFromCGRect(percentageCell.lineTop.frame));
        NSLog(@"P1: %@", NSStringFromCGRect(percentageCell.percentageLine1.frame));

        NSLog(@"LastLine: %f, AllLines: %f", lengthOfLastPercentageLine, percentageLineLength);
        NSLog(@"TopWidth: %f", percentageCell.lineTop.frame.size.width);
        NSLog(@"BottomWidth: %f", percentageCell.lineBottom.frame.size.width);

        NSLog(@"CellWidth1: %f", percentageCell.frame.size.width);
        NSLog(@"CellWidth2: %f", percentageCell.contentView.frame.size.width);

        ...

0 个答案:

没有答案