I'm working on an App where you can track your reading Progress for Books. I have 3 ViewControllers. One is the HomeViewController, where I have a TableView which displays the book. Second is the AddBookController, where you can enter some data, press a Button and create a new row in the TableView. Third is the BookDetailViewController, which is showing when you click on the selected row. Here I am stuck. There is a button you press and the corresponding TableView Cell should update its page number.
Can I use Notification Center for this? There is no Segue from HomeViewController to BookDetailViewController.
HomeViewController
class HomeViewController: UIViewController, UITableViewDelegate, UITableViewDataSource, SendingBookDataProtocol {
#IBOutlet weak var addBookButton: UIButton!
#IBOutlet var tableView: UITableView!
var items = [BookItem]()
override func viewDidLoad() {
super.viewDidLoad()
tableView?.delegate = self
tableView?.dataSource = self
let nib = UINib(nibName: "BookCell", bundle: nil)
tableView?.register(nib, forCellReuseIdentifier: "BookCell")
}
func sendDataToHomeController(bookEntry item:BookItem) {
items.append(item)
tableView.reloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
items.count
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let bookDetailVc = self.storyboard?.instantiateViewController(withIdentifier: "BookDetailView") as? BookDetailViewController
let item = items[indexPath.row]
let currentPageInt = Float(item.currentPage)!
let totalPagesInt = Float(item.totalPages)!
bookDetailVc?.lblName = item.title
bookDetailVc?.lblCurrentPage = item.currentPage
bookDetailVc?.lblTotalPages = item.totalPages
self.navigationController?.pushViewController(bookDetailVc!, animated: true)
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "BookCell", for: indexPath) as! BookCell
let item = items[indexPath.row]
cell.bookImage.image = item.image
cell.title.text = item.title
cell.author.text = item.author
cell.pageNumbers.text = "P. " + item.currentPage + " / " + item.totalPages
cell.title.text = item.title
return cell
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "getBookData" {
let addBookVC: AddBookController = segue.destination as! AddBookController
addBookVC.delegate = self
}
}
}
BookDetailView
class BookDetailViewController: HomeViewController{
#IBOutlet weak var bookTitle: UILabel!
#IBOutlet weak var currentPageDetail: UILabel!
#IBOutlet weak var totalPagesDetail: UILabel!
var lblName = String()
var lblCurrentPage = String()
var lblTotalPages = String()
override func viewDidLoad() {
super.viewDidLoad()
bookTitle.text = lblName
currentPageDetail.text = lblCurrentPage
totalPagesDetail.text = lblTotalPages
}
}
your self.navigationController? is null?
try it
self.present(bookDetailVc!, animated: true)
I hope this helps you.
Related
all.
I am having a problem sending data.
I try to send data from AgentDetailVC to AbilitiesDetailsVC. But i cant. Every data i try to send is nil or empty string.I had managed to send before AgentListVC to AgentDetailsVC. Can y'all examine my code and help me please? Thank you a lot.
This is my AgenListVC.
import UIKit
class AgentListVC: UIViewController {
var agentsReference = ValorantReferenceApp().agents
#IBOutlet var tableView: UITableView!
override func viewDidLoad() {
self.tableView.rowHeight = 100
// tableView.separatorStyle = .none
tableView.delegate = self
tableView.dataSource = self
super.viewDidLoad()
configureNavigationBar()
}
//MARK: - Configure Navigation Bar
func configureNavigationBar() {
self.navigationController?.navigationBar.prefersLargeTitles = true
if var textAttributes = navigationController?.navigationBar.titleTextAttributes {
textAttributes[NSAttributedString.Key.foregroundColor] = UIColor.red
navigationController?.navigationBar.titleTextAttributes = textAttributes
}
}
}
//MARK: - Table View Methods
extension AgentListVC: UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return agentsReference.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell1", for: indexPath) as! AgentCellVC
let agent = agentsReference[indexPath.row]
cell.agentNameLAbel.text = agent.name
cell.agentImageview.image = agent.iconAgent
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
performSegue(withIdentifier: "toSecondVC", sender: nil)
// tableView.deselectRow(at: indexPath, animated: true)
}
//MARK: - Prepare Segue
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let destinationVC = segue.destination as! AgentDetailVC
if let indexPath = tableView.indexPathForSelectedRow {
let agent = agentsReference[indexPath.row]
destinationVC.agentDetailVariables.choosenFlagImage = agent.agentFlagImage
destinationVC.agentDetailVariables.choosenAgentIconImage = agent.iconAgent
destinationVC.agentDetailVariables.choosenAgentType = agent.type.rawValue
destinationVC.agentDetailVariables.choosenAgentName = agent.name
destinationVC.choosenAgentAbilities = agent.abilities
destinationVC.agentDetailVariables.choosenAgentAbilitiesImages = agent.agentAbilitiesImage
destinationVC.choosenAgentVideoLink = agent.skillAbilitiesLink
}
}
}
This is my AgentDetailVC.
import UIKit
class AgentDetailVC: UIViewController {
#IBOutlet var typeLabel: UILabel!
#IBOutlet var characterImageView: UIImageView!
#IBOutlet var flagImageView: UIImageView!
#IBOutlet var tableView: UITableView!
#IBOutlet var agentTypeImageView: UIImageView!
var agentDetailVariables = AgentDetailVariables()
var agentsReference = ValorantReferenceApp().agents
var choosenAgentAbilities = [String]()
var viewController = AbilitiesDetailsViewController()
var choosenAgentVideoLink = [String]()
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
viewLoad()
print(choosenAgentAbilities)
}
//MARK: - ViewLoad Function.
func viewLoad() {
flagImageView.image = agentDetailVariables.choosenFlagImage
characterImageView.image = agentDetailVariables.choosenAgentIconImage
typeLabel.text = agentDetailVariables.choosenAgentType
title = agentDetailVariables.choosenAgentName
tableView.rowHeight = 65
tableView.separatorStyle = .none
agentTypeImageView.image = UIImage(named: "\(agentDetailVariables.choosenAgentType)")
// print(agentDetailVariables.choosenAgentVideoLink)
}
}
//MARK: - TableView Methods
extension AgentDetailVC : UITableViewDelegate, UITableViewDataSource {
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return choosenAgentAbilities.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell2", for: indexPath) as! AgentDetailsCellVC
let agentAbilities = choosenAgentAbilities[indexPath.row]
let skillImages = agentDetailVariables.choosenAgentAbilitiesImages[indexPath.row]
print(agentAbilities)
cell.skillNameLabel.text = agentAbilities
cell.skillImageView.image = skillImages
return cell
}
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
performSegue(withIdentifier: "toYoutubeVideos", sender: nil)
}
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "toYoutubeVideos" {
let destinationVC = segue.destination as! AbilitiesDetailsViewController
if let indexPath = tableView.indexPathForSelectedRow {
let agent = agentsReference[indexPath.row]
let link = choosenAgentVideoLink[indexPath.row]
print(link)
destinationVC.agentAbilitiesVideoURL = link
destinationVC.choosenAgentSkillName = choosenAgentAbilities[indexPath.row]
}
}
}
}
This is my AbilitiesDetailsViewController
import UIKit
import AVKit
import AVFoundation
import MediaPlayer
import MobileCoreServices
import YoutubePlayer_in_WKWebView
class AbilitiesDetailsViewController: UIViewController, AVPlayerViewControllerDelegate {
#IBOutlet var skillDetailsLabel: UILabel!
#IBOutlet var skillNameLabel: UILabel!
#IBOutlet var heroIconImageView: UIImageView!
var agentAbilitiesVideoURL = ""
var choosenAgentSkillName = ""
override func viewDidLoad() {
skillNameLabel.text = choosenAgentSkillName
super.viewDidLoad()
//playAbilitiesVideos()
}
#IBAction func playVideoUsingURL(_ sender: Any) {
playGlobalVideo()
}
func playGlobalVideo() {
guard let videoURL = URL(string: agentAbilitiesVideoURL ?? "sad") else {
return
}
let player = AVPlayer(url: videoURL)
let vc = AVPlayerViewController()
vc.player = player
present(vc, animated: true) {
player.play()
}
}
func playAbilitiesVideos() {
let player = AVPlayer(url: URL(string: "https://assets.contentstack.io/v3/assets/bltb6530b271fddd0b1/bltf4e7a6525fe6ec42/625f2c7cfd9afd4b1fe300ee/C-Prowler_video.mp4")!)
let controller = AVPlayerViewController()
present(controller, animated: true) { }
controller.player = player
addChild(controller)
view.addSubview(controller.view)
controller.view.frame = CGRect(x: 50 , y: 50, width: 300, height: 300)
controller.player = player
controller.showsPlaybackControls = true
player.isClosedCaptionDisplayEnabled = false
player.play()
}
}
This is my struct.
struct Agent: Hashable{
let name: String
let type: AgentType
let origin: String
let abilities: [String]
let iconAgent : UIImage
let agentFlagImage : UIImage
let agentAbilitiesImage: [UIImage]
let skillAbilitiesLink: [String]
}
enum AgentType:String{
case controller = "Controller"
case sentinel = "Sentinel"
case initiator = "Initiator"
case duelist = "Duelist"
}
This is my Agents.
struct ValorantReferenceApp {
static var agentIconImages = AgentIconImages()
static var agentFlagImages = AgentFlagImages()
static var agentAbilitiesImages = AgentAbilitiesImages()
var agents: [Agent] = [
Agent(name: "Brimstone", type: .controller, origin: "United States", abilities: ["Incendiary",
"Stim Beacon",
"Sky Smoke",
"Orbital Strike"],
iconAgent: agentIconImages.iconBrimstone!,
agentFlagImage: agentFlagImages.flagBrimstone!,
agentAbilitiesImage: agentAbilitiesImages.abilitiesBrimstone, skillAbilitiesLink:
["https://assets.contentstack.io/v3/assets/bltb6530b271fddd0b1/blte2b9eb1923ef64fa/5ecad7d0f5bd13348a6cac75/Brimstone_Q_v001_web.mp4",
"https://assets.contentstack.io/v3/assets/bltb6530b271fddd0b1/bltc34c3d692ea83f41/5ecad7d0177c51692beb1fe4/Brimstone_C_v001_web.mp4",
"https://assets.contentstack.io/v3/assets/bltb6530b271fddd0b1/bltcf4359fed083686b/5ecad7d198f79d6925dbee07/Brimstone_E_v001_web.mp4",
"https://assets.contentstack.io/v3/assets/bltb6530b271fddd0b1/blt3d19d83ba51eb18f/5ecad7d297b46c1911ad1868/Brimstone_X_v001_web.mp4"
])
]
In AgentDetailVC you have this code:
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
tableView.deselectRow(at: indexPath, animated: true)
performSegue(withIdentifier: "toYoutubeVideos", sender: nil)
}
When the user selects a Row, the first thing you've done is deselect that row. You then call performSegue.
In prepare(for segue:...) you do this:
if let indexPath = tableView.indexPathForSelectedRow {
So -- tableView.indexPathForSelectedRow will always be nil because you just set it to nil.
Call .deselectRow after you perform the segue.
If I click button I want to pass label in button to the next view. Next view need navigationItem title with label from buttons in previous view.
I've tried segues, but it didn't work. I am trying with instantiate view now, but it also doesn't work (next View appear but without title and needed data)
**HomeTableViewController**
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "workoutFirstCell", for: indexPath) as! WorkoutTableCell
cell.workoutField?.setTitle(workouts[indexPath.row].workoutTitle, for: .normal)
cell.index = indexPath
cell.cellDelegate = self
return cell
} func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "workoutFirstCell", for: indexPath) as! WorkoutTableCell
cell.workoutField?.setTitle(workouts[indexPath.row].workoutTitle, for: .normal)
cell.index = indexPath
cell.cellDelegate = self
return cell
}
extension HomeTableViewController:WorkoutTableCellDelegate {
func onClickCell(index: Int) {
if let vc = storyboard?.instantiateViewController(withIdentifier: "allWorkouts") as? AllWorkoutsViewController {
vc.titleValue = workouts[index].workoutTitle
vc.tableView.reloadData()
}
}
}
Here is my cell controller
protocol WorkoutTableCellDelegate {
func onClickCell(index: Int)
}
class WorkoutTableCell: UITableViewCell {
var cellDelegate:WorkoutTableCellDelegate?
var index: IndexPath?
var item = AllWorkoutsViewController().navigationItem.title
#IBOutlet weak var workoutField: UIButton!
let user = Auth.auth().currentUser
let db = Firestore.firestore()
var models: [DataCell] = []
override func awakeFromNib() {
super.awakeFromNib()
}
#IBAction func buttonTapped(_ sender: Any) {
cellDelegate?.onClickCell(index: (index?.row)!)
}
And View Controller where I want to display navigationItemTitle with label from button in previous view
class AllWorkoutsViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var titleValue: String = ""
let user = Auth.auth().currentUser
var db = Firestore.firestore()
var models: [DataCell] = []
#IBOutlet weak var tableView: UITableView!
override func viewDidLoad() {
super.viewDidLoad()
tableView.delegate = self
tableView.dataSource = self
navigationItem.title = titleValue
You should try this:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
super.prepare(for: segue, sender: nil)
if segue.identifier == "youSegue" {
if let indexPath = self.tableView.indexPathForSelectedRow {
let controller = segue.destination as! YourViewController
controller.title = workouts[indexPath.row]
}
}
}
Essentially, I have the following UITableViewController that contains custom tableView cells with labels in them. When the cell is selected I would like the value of the cell to be passed to the next view controller where I am using it in an HTTP POST response.
What can be added to didSelectRowAt to pass the value of the selected cell to the view controller presented?
Perhaps as a variable?
The following is my code:
import UIKit
class ScheduledCell: UITableViewCell {
#IBOutlet weak var ETALabel: UILabel!
#IBOutlet weak var cellStructure: UIView!
#IBOutlet weak var scheduledLabel: UILabel!
#IBOutlet weak var testingCell: UILabel!
#IBOutlet weak var pickupLabel: UILabel!
#IBOutlet weak var deliveryLabel: UILabel!
#IBOutlet weak var stopLabel: UILabel!
#IBOutlet weak var topBar: UIView!
}
class ToCustomerTableViewController: UITableViewController, UIGestureRecognizerDelegate {
var typeValue = String()
var driverName = UserDefaults.standard.string(forKey: "name")!
var structure = [AlreadyScheduledStructure]()
override func viewDidLoad() {
super.viewDidLoad()
fetchJSON()
//Disable delay in button tap
self.tableView.delaysContentTouches = false
tableView.tableFooterView = UIView()
}
private func fetchJSON() {
guard let url = URL(string: "https://example.com/example/example"),
let value = driverName.addingPercentEncoding(withAllowedCharacters: .urlQueryValueAllowed)
else { return }
var request = URLRequest(url: url)
request.httpMethod = "POST"
request.httpBody = "driverName=\(value)".data(using: .utf8)
URLSession.shared.dataTask(with: request) { data, _, error in
guard let data = data else { return }
do {
self.structure = try JSONDecoder().decode([AlreadyScheduledStructure].self,from:data)
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
catch {
print(error)
}
}.resume()
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return structure.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "scheduledID", for: indexPath) as! ScheduledCell
let portfolio = structure[indexPath.row]
cell.stopLabel.text = "Stop \(portfolio.stop_sequence)"
cell.testingCell.text = portfolio.customer
return cell
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let portfolio = structure[indexPath.row]
let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "scheduledDelivery")
print(portfolio.customer)
controller.navigationItem.title = navTitle
navigationController?.pushViewController(controller, animated: true)
}
override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 200.0
}
}
Create public variables for the data which you want to pass to the scheduledDelivery controller.Then set them inside didselect delegate method. Let say if you want to pass portfolio.customer. Declare following public variable on scheduledDelivery controller.
public var portfilio:String?
Then set value to that variable from the didselect method like this,
let portfolio = structure[indexPath.row]
let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "scheduledDelivery")
controller.portfilio = portfolio.customer
controller.navigationItem.title = navTitle
navigationController?.pushViewController(controller, animated: true)
add a portfolio variable to your next ViewController
class scheduledDeleivery: UIViewController{
var customer:String? //suposing this is customer type
then in
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let portfolio = structure[indexPath.row]
let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "scheduledDelivery") as! shcheduledDeleivery
controller.customer = porfolio.customer //here is the customer you need to pass to next viewcontroller
print(portfolio.customer)
controller.navigationItem.title = navTitle
navigationController?.pushViewController(controller, animated: true)
}
You can store the cell's data as a variable and then in prepare for segue function pass it to the other ViewController. If you call this in prepare for segue it will automatically do it every time you try to access that segue.
var nameOfVar : String = ""
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
var secondVC = segue.destination as! YourSecondViewController
secondVC.variable = nameOfVar
}
Hope I've helped :)
I have a tableview inside a viewcontroller. When pressing a button in the navigation bar I would like the table view to reload.
The view controller is called FirstViewController, the Tableview is called listTableView and the refresh button is called refreshButton
In the code below I have linked the refreshButton action but cannot seem to figure out which function to put inside it to trigger the refresh when pressed.
The following is my code:
import UIKit
class FirstViewController: UIViewController, UITableViewDataSource, UITableViewDelegate, FeedModelProtocol {
var feedItems: NSArray = NSArray()
var selectedStock : StockModel = StockModel()
let tableView = UITableView()
#IBOutlet weak var listTableView: UITableView!
#IBOutlet weak var refreshButton: UIBarButtonItem!
override func viewDidLoad() {
super.viewDidLoad()
//set delegates and initialize FeedModel
self.listTableView.delegate = self
self.listTableView.dataSource = self
let feedModel = FeedModel()
feedModel.delegate = self
feedModel.downloadItems()
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return .lightContent
}
#IBAction func reloadData(_ sender: Any) {
}
func itemsDownloaded(items: NSArray) {
feedItems = items
self.listTableView.reloadData()
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
// Return the number of feed items
return feedItems.count
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
// Retrieve cell
let cellIdentifier: String = "stockCell"
let myCell: UITableViewCell = tableView.dequeueReusableCell(withIdentifier: cellIdentifier)!
myCell.textLabel?.textAlignment = .center
// Get the stock to be shown
let item: StockModel = feedItems[indexPath.row] as! StockModel
// Configure our cell title made up of name and price
let titleStr = [item.customer].compactMap { $0 }.joined(separator: "-")
print(titleStr)
// Get references to labels of cell
myCell.textLabel!.text = titleStr
return myCell
}
}
Use yourUITableView.reloadData() for this. Check Apple's Developer page for more info.
I have a ViewController with two UIButtons and UIlabels.
In order to make similar ViewController of this, I would like to instantiate a new view controller programmatically
like this.
let vc = storyboard.instantiateViewControllerWithIdentifier("Main")
Then navigate to the view controller like this:
navigationcontroller?.pushViewController(vc, animated: true)
I have set StoryBoard ID as "Main", however I do not know where I can write these codes.
class ViewController: UIViewController, AVAudioPlayerDelegate {
let url1 = Bundle.main.bundleURL.appendingPathComponent("music1.mp3")
let url2 = Bundle.main.bundleURL.appendingPathComponent("music2.mp3")
#IBOutlet weak var label1: UILabel!
#IBOutlet weak var label2: UILabel!
#IBOutlet weak var yourButton1: customButton!
#IBOutlet weak var yourButton2: customButton!
override func viewDidLoad() {
super.viewDidLoad()
label1.text = "Hello1"
label2.text = "Hello2"
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
}
func player(url: URL) {
do {
try player = AVAudioPlayer(contentsOf:url)
player.play()
} catch {
print(error)
}
}
#IBAction func pushButton1(sender: UIButton) {
player(url: url1)
}
#IBAction func pushButton2(sender: UIButton) {
player(url: url2)
}
}
tableView
class SecondTableViewController: UITableViewController {
var names = [String]()
var identities = [String]()
override func viewDidLoad() {
names = ["name1","name2","name3","name4"]
identities = ["Main","Main2","Main3","Main4"]
}
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return names.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
let label1 = cell?.viewWithTag(1) as! UILabel
label1.text = "\(names[indexPath.row])"
return cell!
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let vcName = identities[indexPath.row]
let ViewController = storyboard?.instantiateViewController(withIdentifier: vcName)
self.navigationController?.pushViewController(ViewController!, animated: true)
}
}
You need to set Storyboard ID value for the view controller in storyboard and use it here:
let storyboard = UIStoryboard(name: "StoryboardName", bundle: nil)
let vc = storyboard.instantiateViewController(withIdentifier: "RegistrationController")
navigationcontroller?.pushViewController(vc, animated: true)
Edit:
var urls1 = [String]()
var urls2 = [String]()
override func viewDidLoad() {
names = ["name1","name2","name3","name4"]
identities = ["A","B","C","D"]
urls1 = ["url1","url2" ....]
urls2 = ["url1","url2" ....]
}
override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let url1 = urls1[indexPath.row]
let url2 = urls2[indexPath.row]
//let ViewController = storyboard?.instantiateViewController(withIdentifier: vcName) this is wrong you only have one viewcontroller on storyboard and its storyboard id is fixed.
let viewController: ViewController = storyboard?.instantiateViewController(withIdentifier: "StoryboardID") as! ViewController
viewController.url1 = url1
viewController.url2 = url2
self.navigationController?.pushViewController(ViewController!, animated: true)
}