我想在我的ViewController的东西,应该是相同的这幅画(简单密码+单选按钮)的第一项补充。我是否需要使用UITableView并为此定义听者和页脚?有人能给我提供一些如何开始和使用它的例子吗?
0
A
回答
1
您需要在单元左侧使用UILabel以及在右侧使用UISwitch的自定义UITableViewCell。
向表格视图和单元格标识符注册自定义单元格类,然后像对其他单元格一样对其进行自定义。
static NSString *const CellIdentifier = @"customCell";
/**
* Called after the controller’s view is loaded into memory.
*/
- (void)viewDidLoad
{
[super viewDidLoad];
[self.tableView registerClass:[CustomCell class] forCellIdentifier:CellIdentifier];
}
/**
* Asks the data source for a cell to insert in a particular location of the table view.
*
* @param tableView A table-view object requesting the cell.
* @param indexPath An index path locating a row in tableView.
*
* @return An object inheriting from UITableViewCell that the table view can use for the specified row.
*/
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
CustomCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = @"Simple Passcode";
return cell;
}
+0
如果班级我使用的CustomCell是一个UIViewController,我有UITableview,当使用[_tableView注册...]我得到一个错误信息没有可见的接口UITableView声明选择器寄存器。如何解决这个问题? –
0
最简单的解决方案是在界面构建器中使用静态布局来设置UITableViewController。
然后设置你的表,但是你希望它看起来:
相关问题
- 1. 如何添加单选按钮
- 2. 添加单选按钮
- 3. 如何在按钮组中添加单选按钮?
- 4. C#帮助为菜单添加单选按钮/选项按钮
- 5. 添加一个单选按钮的UITableViewCell通过动画:iOS的
- 6. 如何在settings.bundle中添加按钮ios
- 7. 如何在IOS一个单选按钮
- 8. 如何根据选中的单选按钮为div添加类?
- 9. 如何添加单选按钮到Tkinter的子菜单中
- 10. 如何在Symfony2 Forms中添加单独的单选按钮?
- 11. Swift iOS-如何将按钮添加到CollectionView单元的外部
- 12. 如何在ios 7的底部uiwebview添加添加按钮?
- 13. 如何添加单选按钮以选择行
- 14. 如何通过单击按钮添加多选复选框
- 15. 如何在Yii单选按钮中添加html属性选项?
- 16. 如何添加单选按钮有多种选择
- 17. 如何选择单选按钮时添加课程标签?
- 18. 如何在wordpress小部件表单中添加单选按钮
- 19. CakePHP - 如何将属性添加到单个单选按钮?
- 20. 如何将单选按钮添加到菜单项?
- 21. 如何添加(总和)单个单选按钮组?
- 22. 如何在菜单栏中添加单选按钮,qt 5 C++
- 23. 如何在单击单选按钮上添加两个功能
- 24. 如何向表单垂直添加单选按钮?
- 25. Flash单选按钮:如何获取选定的单选按钮?
- 26. 动态添加单选按钮
- 27. 将单选按钮添加到Tkinter
- 28. 动态添加单选按钮
- 29. 使用jQuery添加单选按钮
- 30. PHP DOM添加单选按钮
我建议你创建一个UITableViewController(或您的自定义类从的UITableViewController inerrited),创建一个UITableViewCell与基本的UILabel和UISwitch,就是这样。使插座连接,瞧:)。这里有一个老例子,但你有这个想法:http://stackoverflow.com/questions/4585840/how-to-create-a-uitableviewcell-with-a-uiswitch-and-get-the-data – Lapinou