SWReveal问题(幻灯片菜单)

时间:2017-05-21 07:37:12

标签: ios swift xcode swrevealviewcontroller

我遇到以下代码的问题:

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()
    }
}

登录后所有这些......

1 个答案:

答案 0 :(得分:0)

这一行是问题

func tableView(_ tableView:UITableView,didDeselectRowAt indexPath:IndexPath)

didDeselectRowAt to didselectRowAt