3 回答
TA贡献1775条经验 获得超8个赞
UITableView
tableView: heightForRowAtIndexPath:
[tableView beginUpdates];[tableView endUpdates];
UITableView
TA贡献1854条经验 获得超8个赞
int currentSelection;
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { int row = [indexPath row]; selectedNumber = row; [tableView beginUpdates]; [tableView endUpdates];}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath { if ([indexPath row] == currentSelection) { return 80; } else return 40;}
TA贡献1982条经验 获得超2个赞
@property (nonatomic) int currentSelection;
viewDidLoad
UITableView
- (void)viewDidLoad{ [super viewDidLoad]; // Do any additional setup after loading the view. //sentinel self.currentSelection = -1;}
heightForRowAtIndexPath
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{ int rowHeight; if ([indexPath row] == self.currentSelection) { rowHeight = self.newCellHeight; } else rowHeight = 57.0f; return rowHeight;}
didSelectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { // do things with your cell here // set selection self.currentSelection = indexPath.row; // save height for full text label self.newCellHeight = cell.titleLbl.frame.size.height + cell.descriptionLbl.frame.size.height + 10; // animate [tableView beginUpdates]; [tableView endUpdates]; }}
didDeselectRowAtIndexPath
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath { // do things with your cell here // sentinel self.currentSelection = -1; // animate [tableView beginUpdates]; [tableView endUpdates]; }}
- 3 回答
- 0 关注
- 707 浏览
添加回答
举报