ios - 当 UIStepper 增加值时如何显示 UISwitch
问题描述
我想做一个关于何时单击 UIStepper 并将其递增到 1 的任务。然后应该出现一个开关,当再次单击 UIStepper 时,另一个开关应该显示在第一个开关下方。
当 UIStepper 增加时,我需要垂直显示至少 5 个开关。
-(void)onstepperClicked:(UIStepper*)selectedComponent {
if (selectedComponent == self.mainStepper) {
if (self.mainStepper.value >=0) {
float y=20;
//output label
self.outputLabel.text = [NSString stringWithFormat:@"%d",(int)self.mainStepper.value ];
// slider animated with stepper
[self.mainSlider setValue:self.mainStepper.value animated:YES];
//switch
self.repeatingSwitch = [[UISwitch alloc]init];
self.repeatingSwitch.frame=CGRectMake(20,y+50,100, 100);
[self.view addSubview:self.repeatingSwitch];
self.repeatingSwitch.tintColor=[UIColor redColor];
self.repeatingSwitch.onTintColor=[UIColor greenColor];
self.repeatingSwitch.thumbTintColor =[UIColor blackColor];
}
}
}
解决方案
在笔尖中设计一个自定义单元格,UISwitch
里面只有一个。然后在您设计的称重传感器UITableView
下方设置一个。UIStepper
当您单击时,UIStepper
只需增加UITableViewDataSource
方法中的行数。
推荐阅读
- mysql - 如何在mysql中的多个连接中限制和搜索表中的连接行数
- react-native - 当 UserLocation 在 Marker 之上时反应原生地图回调
- asp.net - .NET 5 控制台应用程序使用 Dropbox webhook
- azure - 如何对 POST Azure API 调用进行身份验证?
- swift - “MISSING_OR_INVALID_NONCE:请求中缺少 Nonce。”
- python - 在 Heroku 上设置 gdal/osgeo Python 库
- sql - 我需要代码只显示 LAB_ORD.Order_Status 中的 F 和 C 不幸的是,代码无法识别此命令并显示 F、C、X、P
- google-cloud-platform - 如何获取有关 Google Scope ID 的信息?
- rundeck - 如何使用 CLI 更新 Rundeck 项目设置
- swift - 如何将视野降低到安全区域?