2

I have a static UITableView and want to hide a table cell (exactly I want to hide the datepicker in the cell). I want to do this in the heightForRowAtIndexPath method:

public override float GetHeightForRow (UITableView tableView, NSIndexPath indexPath)
{
    float height = this.TableView.RowHeight;

    if (indexPath.Row == 5 || indexPath.Row == 7) {
        height = 0.0f;
    }

    return height;
}

When I'm doing this the content of the cell overlaps with the other content. In my case the datepicker takes the whole screen. The same goes for labels and so on. Also it seems that the separator line is still there.

How can I remove or hide a cell with it's content temporarily?

You don't have to provide a C# solution. I will translate it by myself. BTW: I'm using iOS 7.1

4

3 に答える 3

3

IB のセルに「Clip Subviews」をチェックします。セルの「コンテンツ ビュー」ではありません。

これをコードでアーカイブするには:

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [super tableView:tableView cellForRowAtIndexPath:indexPath];
    if(indexPath.row == 5 || indexPath.row == 7) {
        cell.clipsToBounds = YES;
    }
    return cell;
}
于 2014-09-18T09:16:43.220 に答える
0

メソッドを更新することをお勧めします-

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
     if (indexPath.Row == 5 || indexPath.Row == 7) {
        return 0.0f;
     }
    return 50; // some static value
}

これで問題が解決することを願っています。

于 2014-09-18T08:51:32.387 に答える
0

でこれを削減numberOfRowsInSection:して検討しようとしますがcellForRowAtIndexPath:、それが機能するかどうかは 100% わかりません。

于 2014-09-18T08:48:05.603 に答える