简体   繁体   English

如何将UISwitch添加到分组表视图中的单元格?

[英]How to add a UISwitch to a cell in a grouped table view?

So I'm creating a settings page in my app and up to now I've set it up with a grouped table view with both group titles and settings/cell tiles. 因此,我正在应用程序中创建一个设置页面,到目前为止,我已经使用分组表视图对其进行了设置,其中包含组标题和设置/单元格图块。

At this point I'd like to add UISwitches (Already have their properties set up) to each cell. 在这一点上,我想向每个单元格添加UISwitches(已经设置了它们的属性)。 How can I do that? 我怎样才能做到这一点?

The easiest way is to add a UISwitch as the accessory view for the UITableViewCell . 最简单的方法是将UISwitch添加为UITableViewCell的附件视图。

UISwitch* aswitch = [[UISwitch alloc] initWithFrame:CGRectZero];
aswitch.on = YES; // or NO
cell.accessoryView = aswitch;
[aswitch release];

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如果我将UISwitch控件添加到每个表视图单元格中,如何判断它属于哪个单元格? - If I add a UISwitch control to each of my table view cells, how can I tell which cell it belongs to? 如何在Table View ViewDidLoad方法中调用自定义单元格中声明的UISwitch? - How to call UISwitch declared in Custom Cell in Table View ViewDidLoad method ? 在分组模式下向表格视图单元格添加渐变背景 - Add a gradient background to a table view cell in grouped mode 如何自定义分组的表格视图单元格的背景/边框颜色? - How to customize the background/border colors of a grouped table view cell? 如何在表格视图单元格中设置背景颜色+不透明度+样式分组 - how to set background color + opacity in table view cell + style is grouped 如何在iPhone中的分组表视图单元格中创建文本字段 - How to create a Text Field in Grouped Table view Cell in iPhone 分组表视图 - 实现选择了哪个单元格 - Grouped Table View - Realizing which cell was selected iPhone分组表视图单元重用 - iPhone grouped table view cell reuse 如何在分组表格视图的行中添加更多2个或更多标签 - how to add more 2 or more labels in a row of grouped table view 如何在表格视图单元格中添加复选框? - How to Add Check Box in Table View Cell?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM