草庐IT

TableView

全部标签

ios - 将标题添加到 TableViewController

我想知道如何为我的swift项目添加一个简单的标题。我在表格View中列出了学生,只想在列表上方的中心添加一个标题,上面写着“学生”,但我一辈子都弄不明白。每次我尝试添加任何东西时,它要么妨碍运营商设置,要么不出现。他是我的代码,除了一个尝试的标题block。classStudentRosterTableViewController:UITableViewController{varstudentsList=[Dictionary]()overridefuncviewDidLoad(){super.viewDidLoad()letstudentRoster=ClassRosterMod

ios - 发送到实例的 UITableView 无法识别的选择器

我对发生的事情感到困惑我正在做一个关于CollectionView的教程,因为我对编程还很陌生,我相信我做的一切都是正确的,但我被击中了-[UIViewtableView:numberOfRowsInSection:]:发送到实例的无法识别的选择器。教程如下:http://www.thorntech.com/2015/08/want-your-swift-app-to-scroll-in-two-directions-like-netflix-heres-how/importUIKitclassViewController:UIViewController,UITableViewDat

ios - reloadData 之后未调用 cellForRowAtIndexPath 但 numberOfRowsInSection 调用

在我当前的项目中,我正在尝试从REST端点获取新闻,并且我想在网络请求完成后刷新UITableView。所以我调用了reloadData()但不幸的是cellForRowAtIndexPath没有被调用,但是numberOfRowsInSection被调用并返回了正确的项目数。按照我的代码精简到相关部分:classNewsTableViewController:UIViewController{privatevarnewsItems:Array!privatevartableView:UITableView!overridefuncviewDidLoad(){super.viewDid

ios - Swift 3 - 第一个单元格已经展开的可展开表格 View 单元格

我正在使用Swift3。我已按照本教程获取它,以便我可以点击一个表格View单元格,该单元格将展开以显示更多信息。https://www.youtube.com/watch?v=VWgr_wNtGPM&t=294s我的问题是:我该怎么做才能在View已经加载时展开第一个单元格(即用户不必单击以查看该单元格展开)但所有其他行为保持不变(例如,如果再次单击它,它会取消折叠)?UITableViewCell:importUIKitclassResultsCell:UITableViewCell{@IBOutletweakvarintroPara:UITextView!@IBOutletwea

ios - 如何在 IGListKit 中添加 sectionHeader,如 tableview header

IGListKit库链接:https://github.com/Instagram/IGListKit我正在使用IGListKit制作不同的截面单元格。我成功地完成了这项任务,但我无法使用iglistKit为不同的部分添加标题 最佳答案 从IGListKit2.1开始,考虑以IG为前缀的类和协议(protocol)名称。从3.0开始删除了此前缀。在您的部分Controller类中,除了从IGListSectionController继承(并在IGListKit2.x上实现IGListSectionType)之外,您还需要实现IGLi

xcode - 无法将 UITableViewDataSouce 和 UITableViewDelegate 设置为 UIViewController

当我尝试将委托(delegate)和数据源设置为UIViewController时,所有在UITableViewController中正常运行的函数都被检测为错误。funcnumberOfSectionsInTableView(tableView:UITableView!)->Int{//#warningPotentiallyincompletemethodimplementation.//Returnthenumberofsections.return1}functableView(tableView:UITableView!,numberOfRowsInSectionsection

ios - 选择和取消选择 UITableViewCells - Swift

目前我可以点击一个单元格并使用didSelectRowAtIndexPath选择它。但是,我无法在点击时取消选择它。我想切换这两个功能。functableView(tableView:UITableView,didSelectRowAtIndexPathindexPath:NSIndexPath){varselectedCell=tableView.cellForRowAtIndexPath(indexPath)!selectedCell.backgroundColor=UIColor.purpleColor()tableView.deselectRowAtIndexPath(inde

ios - UITableViewCell 快速重复每 12 行

使用以下代码,当我单击一个单元格以创建复选标记配件时,它会每12行重复复选标记。关于原因有什么想法吗?functableView(tableView:UITableView,cellForRowAtIndexPathindexPath:NSIndexPath)->UITableViewCell{letcell=tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath:indexPath)as?UITableViewCellcell?.textLabel="\(indexPath.row)"returncell!}fu

ios - 为什么 numberOfRowsInSection 仅针对一个部分被多次调用?

//VariableandViewDidLoadvarauxRow=0varauxSection=0overridefuncviewDidLoad(){super.viewDidLoad()}//NumberOfSections,只有一个sectionoverridefuncnumberOfSectionsInTableView(tableView:UITableView)->Int{auxSection+=1print("timessection:",auxSection)return1}//行数overridefunctableView(tableView:UITableView,

ios - : tableView. cellForRow 和 dataSource.cellForRowAtIndexPath 之间的区别

目前我正在做一个项目和开始的开发人员用于访问单元格的项目dataSource.cellForRowAtIndexPath(indexPath)但我习惯于使用访问单元格cellForRow(at:indexPath)有谁知道其中的区别,哪个更好用?我问的原因是dataSource.cellForRowAtIndexPath(indexPath)导致了我们这次崩溃。***Terminatingappduetouncaughtexception'NSInternalInconsistencyException',reason:'Attemptedtodequeuemultiplecellsf