創建你想顯示無論你的細胞和選擇器:
-----------------------------------
cell visible part
-----------------------------------
cell invisible part (with picker)
-----------------------------------
定義,讓你知道,如果你要顯示整個單元的屬性:
@property (nonatomic) BOOL shouldShowPicker;
初始化這個屬性(例如viewDidLoad);
self.shouldShowPicker = NO;
一對夫婦的方法來摸:
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if(indexPath.row == 4) { //where your picker row is
self.shouldShowPicker = YES;
[self.tableView reloadRowsAtIndexPaths:@[indexPath] withRowAnimation:UITableViewRowAnimationAutomatic];
}
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
if(indexPath.row == 4 && self.shouldShowPicker) { //where your picker row is
return CELL_VISIBLE_PLUS_INVISIBLE_PART;
} else if(indexPath.row == 4 && !self.shouldShowPicker) {
return return CELL_VISIBLE_PART;
} else {
return OTHER_CELLS_HEIGHT;
}
}