serdar aylanc
serdar aylanc

Reputation: 1347

SWRevealViewController open tableview when cell selected - Swift

I am using SWRevealViewController, I have three cells like "first" "second" "last". And I have three different tableviews, "firstTableViewController", "secondTableViewController", "lastTableViewController".

I tried to use didSelectRowAtIndexPath, the prepareforsegue. But I couldn't implement multipe segues in didSelectRowAtIndexPath.

Is there a way to do this?

import UIKit

class SideBarTableViewController: UITableViewController {

    var MenuArray = [String]()

    override func viewDidLoad() {
        super.viewDidLoad()
        MenuArray = ["First","Second","Last"]
        var view = UIView(frame: CGRectZero)
        self.tableView.tableFooterView = view
        self.tableView.backgroundColor = UIColor.whiteColor()
    }
    override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return MenuArray.count
    }
    override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
        var cell = tableView.dequeueReusableCellWithIdentifier(MenuArray[indexPath.row], forIndexPath: indexPath) as UITableViewCell
        cell.textLabel?.text = MenuArray[indexPath.row]
        return cell
    } 
}

cell identifiers : First, Second, Last

Thanks,

Upvotes: 2

Views: 816

Answers (1)

serdar aylanc
serdar aylanc

Reputation: 1347

Ok, I found the solution. Followed this tutorial, there is no need to set a segue in code, just kntrl+drag to the view controllers and select "SWRevealViewControllerSeguePushController" ...

http://www.appcoda.com/sidebar-menu-swift/

Upvotes: 1

Related Questions