公告
财富商城
积分规则
提问
发文
2019-09-19 23:50发布
迷人小祖宗
how do I add a UIStepper to every cell of my UITableView programmatically?
Thanks
Luca
One way to do it is to add the UIStepper to each cell as a subview in tableView:cellForRowIndexAtPath in your TableViewController. For example:
- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString* CellIdentifier = @"Cell"; UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier]; if (cell == nil) { cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier]; UIStepper* stepper = [[UIStepper alloc] init]; stepper.frame = CGRectMake(220, 10, 100, 10); [cell.contentView addSubview: stepper]; } return cell; }
This will add a stepper to the right-hand side of each cell in your table.
最多设置5个标签!
One way to do it is to add the UIStepper to each cell as a subview in tableView:cellForRowIndexAtPath in your TableViewController. For example:
This will add a stepper to the right-hand side of each cell in your table.