【发布时间】:2017-10-21 00:25:32
【问题描述】:
我对以下代码有疑问:
class VCParticipanteMenu: UIViewController,UITableViewDelegate,UITableViewDataSource
{
var menuNameArr:Array = [String]()
var iconeImage:Array = [UIImage]()
override func viewDidLoad() {
super.viewDidLoad()
menuNameArr = ["Inicio","Actividades","Información","Mapa","Comunicación","Perfil","FeedBack!","Cerrar Sesión"]
iconeImage = [UIImage(named: "Inicio")!,UIImage(named: "eventos")!,UIImage(named: "informacion")!,UIImage(named: "mapa")!,UIImage(named: "comunicacion")!,UIImage(named: "perfil")!,UIImage(named: "feedback")!,UIImage(named: "cerrarSesion")!]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return menuNameArr.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "TVCParticipanteMenu") as! TVCParticipanteMenu
cell.imgIcon.image = iconeImage[indexPath.row]
cell.lblView.text = menuNameArr[indexPath.row]
print(cell.lblView.text!)
return cell
}
func tableView(_ tableView: UITableView, didDeselectRowAt indexPath: IndexPath) {
let revealViewController:SWRevealViewController = self.revealViewController()
let cell:TVCParticipanteMenu = tableView.cellForRow(at: indexPath) as! TVCParticipanteMenu
print(cell.lblView.text!)
if cell.lblView.text! == "Inicio"
{
let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let desController = mainStoryboard.instantiateViewController(withIdentifier: "VCParticipante") as! VCParticipante
let newFrontViewController = UINavigationController.init(rootViewController:desController)
revealViewController.pushFrontViewController(newFrontViewController, animated: true)
}
if cell.lblView.text! == "Actividades"
{
let mainStoryboard:UIStoryboard = UIStoryboard(name: "Main", bundle: nil)
let desController = mainStoryboard.instantiateViewController(withIdentifier: "VCParticipanteAct") as! VCParticipanteAct
let newFrontViewController = UINavigationController.init(rootViewController:desController)
revealViewController.pushFrontViewController(newFrontViewController, animated: true)
}
}
一切都好,但在选择“Inicio”或“Actividades”的那一刻什么都没有出现,在选择另一个选项后我出现了上面等等
这是其他viewControllers的代码
import UIKit
class VCParticipante: UIViewController {
@IBOutlet weak var menuButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
menuButton.target = revealViewController()
menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
和
import UIKit
class VCParticipanteAct: UIViewController {
@IBOutlet weak var menuButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
menuButton.target = revealViewController()
menuButton.action = #selector(SWRevealViewController.revealToggle(_:))
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
}
所有这一切都在登录后...
【问题讨论】:
标签: ios swift xcode swrevealviewcontroller