pushViewController

 

// SimpleVC ViewController.swift

func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath)
{
//let site = sites[indexPath.row] as LectureSite
//selectedURL = site.url
//self.performSegueWithIdentifier(“ShowSimpleVCSegue”, sender: self)

tableView.deselectRowAtIndexPath(indexPath, animated: true)
print(“You selected cell #\(indexPath.row)”)

let site = sites[indexPath.row] as LectureSite
let aViewController: SimpleViewController = storyboard?.instantiateViewControllerWithIdentifier(“SimpleViewController”) as! SimpleViewController
aViewController.name = site.name
aViewController.imageName = site.imageName
aViewController.url = site.url
navigationController?.pushViewController(aViewController, animated: true)
}

 

// SimpleVC SimpleViewController,swift

@IBAction func buttonPressed(sender: AnyObject) {
if let button = sender as? UIButton {
if button == aButton {
self.performSegueWithIdentifier(“ShowDetailVCSegue”, sender: self)
}
else if button == bButton {
self.performSegueWithIdentifier(“ShowOtherDetailVCSegue”, sender: self)
}
}
}

override func prepareForSegue(segue: UIStoryboardSegue, sender: AnyObject?) {

// Get the new view controller using segue.destinationViewController.
// Pass the selected object to the new view controller.
if (segue.identifier == “ShowDetailVCSegue”) {
if let destinationVC = segue.destinationViewController as? DetailViewController {
destinationVC.name = name
destinationVC.imageName = imageName
}
}
else if (segue.identifier == “ShowOtherDetailVCSegue”) {
if let destinationVC = segue.destinationViewController as? OtherDetailViewController {
destinationVC.name = name
destinationVC.url = url
}
}
}

Leave a Reply

Your email address will not be published. Required fields are marked *