swift - embedded SWRevealViewController to you application

213 views Asked by At

I intergrade SWRevealViewController to my project

my project flow is viewcontroller ---> SWRevealViewController -->menu --> nav-->front view

the segue method from my initial view controller to SWRevealViewController is model

my problem is when my I open toggle in front view for first time only

it give me empty menu(table view)

my front view code

@IBOutlet weak var open: UIBarButtonItem!
    @IBOutlet weak var result: UILabel!

    @IBAction func showmore(sender: AnyObject) {
        performSegueWithIdentifier("resdes", sender: sender)
    }



    override func viewDidLoad() {
        super.viewDidLoad()


       var res =  Uti.get_result()
        result.text = res.description

        open.target = self.revealViewController()
        open.action = Selector("revealToggle:")
        self.view.addGestureRecognizer(self.revealViewController().panGestureRecognizer())

        // Do any additional setup after loading the view.
    }

my rear code

class slidemenuVC : UITableViewController{

    var menuItems = [String]()

    override func viewDidAppear(animated: Bool) {
        menuItems = ["Result","About us","References","Rest Test"]
    }

    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return menuItems.count
    }

    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier(menuItems[indexPath.row], forIndexPath: indexPath) as UITableViewCell

        cell.textLabel?.text = menuItems[indexPath.row]
        return cell

    }


}

enter image description here

Second problem :

when I press at first menu item , navigation disappear

enter image description here

it should be like this have toggle

1

There are 1 answers

0
John D On
var cell = tableView.dequeueReusableCellWithIdentifier(menuItems[indexPath.row], forIndexPath: indexPath) as UITableViewCell

is wrong. You need your identifier has to be the actual cell id in your uitableviewcell