mardi 1 juin 2021

Connecting Button on a secondary ViewController to a Website on Xcode

I'm using Xcode and I'm able to connect a button to a URL on the original ViewController coding window which will take the user to the website. However, when I try to do so with a new Cocoa Touch Class to forward a new button on a different View Controller, the same code does not work and the button does nothing. Is there something I'm missing?

'''

import UIKit

class HulkViewController: UIViewController {

override func viewDidLoad() {
    super.viewDidLoad()

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

override func didReceiveMemoryWarning() {
    super.didReceiveMemoryWarning()
}

@IBAction func hulkBtn(_ sender: Any) {
    UIApplication.shared.open(URL(string:"www.google.com/")! as URL, options:[:], completionHandler:nil)
    

        }
}

'''




Aucun commentaire:

Enregistrer un commentaire