Reputation: 20289
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
Upvotes: 2
Views: 1495
Reputation: 51911
Check "Clip Subviews" to your cell in IB. not for "Content View" of cell.
To arhchive this by code:
- (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;
}
Upvotes: 3
Reputation: 156
I recommend you to update the method-
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.Row == 5 || indexPath.Row == 7) {
return 0.0f;
}
return 50; // some static value
}
I hope this will solve your problem.
Upvotes: 0
Reputation: 346
i would try to reduce numberOfRowsInSection:
and consider this in cellForRowAtIndexPath:
, but i'm not 100% sure if that works.
Upvotes: 0