【发布时间】:2018-03-21 03:46:43
【问题描述】:
如何在UITableView 中创建单行视图分隔符,就像 Android 的 NavigationDrawer:
我知道在 Android 中这很容易,但我找不到 iOS 的参考,它是如何在 iOS 上调用的,我只想在我的菜单视图中添加一个单行分隔符,以及我所有的视频和教程can find for iOS 展示了如何添加可扩展菜单,这不是我想要的,我只想要一行分隔两组字符串数组。在 iOS 上可以吗,我在哪里可以找到教学教程?
到目前为止我的代码:
import UIKit
class MenuViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
//Outlets
@IBOutlet weak var tableView: UITableView!
var menuNameArr = [String]()
var iconImage = [UIImage]()
override func viewDidLoad() {
super.viewDidLoad()
tableView.alwaysBounceVertical = false;
tableView.separatorStyle = .none
menuNameArr = ["Meu Perfil", "Meus Cupons", "Extrato de pontos", "Configurações", "Termos de uso", "Entre em Contato", "Avaliar aplicativo", "Sair"]
iconImage = [UIImage(named: "user")!,UIImage(named: "cupons")!, UIImage(named: "extrato")!, UIImage(named: "config")!, UIImage(named: "termos")!, UIImage(named: "contato")!, UIImage(named: "avaliar")!, UIImage(named: "sair")!]
self.revealViewController().rearViewRevealWidth = self.view.frame.size.width - 60
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuNameArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "MenuTableViewCell") as! MenuTableViewCell
cell.imgIcon.image = iconImage[indexPath.row]
cell.lblMenuName.text! = menuNameArr[indexPath.row]
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
}
}
从“Configurações”到“Sair”我希望数组的那一部分成为菜单的第二部分
【问题讨论】:
-
只需将线条的绘图添加到该单元格的绘图中即可。
-
stackoverflow.com/questions/20283505/… 和许多其他人的副本
标签: ios swift uitableview uiviewcontroller