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 關注
- 746 瀏覽
添加回答
舉報