
>当我触摸任何单元格并向上/向下移动时,它不会滚动.
>但是,如果我开始使用UItableVIEwCell的任一端滚动(几乎是左边的15px),它会滚动.
我试图创建另一个新的tableVIEw,仍然无法正常工作.
我试图创建一个tableVIEwController,仍然无法正常工作.
然后我认为代码不是问题的原因.
使用Xcode 8.2.1
以下是我的代码工作:
类文件
struct Quote { var text: String}class VIEwController: UIVIEwController,UItableVIEwDataSource,UItableVIEwDelegate { @IBOutlet var tableVIEw: UItableVIEw? let cellIDentifIEr = "cell" // Array of strings for the tableVIEw var tableData = [Quote(text: "zadz ad azd azds fsd gdsfsd"),Quote(text: "zakd gqsl jDWld bslf bs ldgis uqh dm sd gsql ID hsqdl sgqhmd osq bd zao mos qd"),Quote(text: "azdhsqdl sb ljd ghdlsq h ij dgsqlim dhsqihdùa dbz ai lJsm oqjdvl isq dbvksqjld"),Quote(text: "dsqb jhd gs qdgsq dgsq u hdgs qli hd gsql i dgsq li dhs qij dhlqs dqsdsd.")] overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() self.tableVIEw?.register(UItableVIEwCell.self,forCellReuseIDentifIEr: self.cellIDentifIEr) } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() } func numberOfSections(in tableVIEw: UItableVIEw) -> Int { return 1 } func tableVIEw(_ tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int { // Return number of rows in table return tableData.count } func tableVIEw(_ tableVIEw: UItableVIEw,cellForRowAt indexPath: IndexPath) -> UItableVIEwCell { // Create Resusable Cell,get row string from tableData let cell = tableVIEw.dequeueReusableCell(withIDentifIEr: self.cellIDentifIEr)! as! cellClass let row = indexPath.row // Set the labels in the custom cell cell.mainText.text = tableData[row].text return cell } func tableVIEw(_ tableVIEw: UItableVIEw,dIDSelectRowAt indexPath: IndexPath) { // Do what you want here let selectValue = self.tableData[indexPath.row] print("You selected row \(indexPath.row) and the string is \(selectValue)") } } 这是我的cellClass :(自定义单元格)
class cellClass: UItableVIEwCell { @IBOutlet weak var mainText: UILabel! overrIDe func awakeFromNib() { super.awakeFromNib() // Initialization code } overrIDe func setSelected(_ selected: Bool,animated: Bool) { super.setSelected(selected,animated: animated) // Configure the vIEw for the selected state }} UItableVIEw的故事板层次结构
解决方法 你可能会遇到一些x-code问题,因为通常它永远不会发生,我运行你的项目它正常工作,因为它通常工作.以下是我所做的代码工作.
我不像你那样采用阵列结构,我只是采用简单的数组.
我的阵列是
arrayData = ["One","Two","three","four"]
下面是cellForRow
func tableVIEw(_ tableVIEw: UItableVIEw,cellForRowAt indexPath: IndexPath) -> UItableVIEwCell { let cell : cellClass = tableVIEw.dequeueReusableCell(withIDentifIEr: "Cell",for: indexPath) as! cellClass cell.lblstates.text = arrayData[indexPath.row] return cell} 如果您遇到任何问题,请告诉我.
总结以上是内存溢出为你收集整理的ios – 滚动单元格时UITableView不滚动全部内容,希望文章能够帮你解决ios – 滚动单元格时UITableView不滚动所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)