import UIKitclass FourthVIEwController: UIVIEwController { @IBOutlet weak var tableVIEw: UItableVIEw! let cellname = "cell" let mytableVIEwCellIDentifIEd = "MytableVIEwCell" overrIDe func vIEwDIDLoad() { super.vIEwDIDLoad() prepareUI() // Do any additional setup after loading the vIEw. } // 准备UI private func prepareUI() { navigationItem.Title = "我的" self.tableVIEw.delegate = self self.tableVIEw.dataSource = self // 注册 tableVIEw.registerClass(UItableVIEwCell.self,forCellReuseIDentifIEr: cellname) //注册 tableVIEw.registerNib(UINib(nibname: mytableVIEwCellIDentifIEd,bundle: nil),forCellReuseIDentifIEr: mytableVIEwCellIDentifIEd) //去除tableVIEw 多余行的方法 添加一个tableFooterVIEw 后面多余行不再显示 tableVIEw.tableFooterVIEw = UIVIEw() } overrIDe func dIDReceiveMemoryWarning() { super.dIDReceiveMemoryWarning() // dispose of any resources that can be recreated. } /* // MARK: - Navigation // In a storyboard-based application,you will often want to do a little preparation before navigation overrIDe func prepareForSegue(segue: UIStoryboardSegue,sender: AnyObject?) { // Get the new vIEw controller using segue.destinationVIEwController. // Pass the selected object to the new vIEw controller. } */}extension FourthVIEwController: UItableVIEwDelegate,UItableVIEwDataSource { func tableVIEw(tableVIEw: UItableVIEw,numberOfRowsInSection section: Int) -> Int { if section == 0 { return 1 } else if section == 1{ return 3 } else if section == 2 { return 5 } else { // do nothing. return 0 } } func numberOfSectionsIntableVIEw(tableVIEw: UItableVIEw) -> Int { return 3 } func tableVIEw(tableVIEw: UItableVIEw,heightForRowAtIndexPath indexPath: NSIndexPath) -> CGfloat { if indexPath.section == 0 { return 44 } else { return 50 } } func tableVIEw(tableVIEw: UItableVIEw,TitleForheaderInSection section: Int) -> String? { if section == 0 { return "第一组" } else if section == 1{ return "第二组" } else { return "第三组" } } func tableVIEw(tableVIEw: UItableVIEw,cellForRowAtIndexPath indexPath: NSIndexPath) -> UItableVIEwCell { let cell = tableVIEw.dequeueReusableCellWithIDentifIEr(cellname,forIndexPath: indexPath) as UItableVIEwCell if indexPath.section == 0 { cell.textLabel?.text = "123" } else if indexPath.section == 1{ cell.textLabel?.text = "test" } else { let cell = tableVIEw.dequeueReusableCellWithIDentifIEr(mytableVIEwCellIDentifIEd,forIndexPath: indexPath) as! MytableVIEwCell cell.textLabel?.text = "work" } return cell }}总结
以上是内存溢出为你收集整理的swift- 去除tableView 多余行全部内容,希望文章能够帮你解决swift- 去除tableView 多余行所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)