0

I am trying that when I press the image it takes me to the link

I have this:

class CoverPillCell: TableViewCell {

@IBOutlet weak var imagePill: UIImageView!


@IBOutlet weak var imagenButton: UIButton!

this contains variables that later in the load function call the remoteconfig

    height = CGFloat(promoPill?.image_height ?? 0)
    width = CGFloat(promoPill?.image_width ?? 0)
    target_url = promoPill?.target_url ?? ""
    position = promoPill?.position ?? 0

    if enabled == true {
        enabled = ((promoPill?.enabled) != nil)
    }
    //This is what I'm trying to when tap go to the target url which is configured on the remote config
    if imagenButton.isUserInteractionEnabled == true {
        self.imagenButton.addTarget(self, action: #selector(tapPill(_:)), for: .touchUpInside)
    }

And in the IBAction I'm trying this:

  @IBAction func tapPill(_ sender: UIButton) {
    let promoPill = getPromoPill()
    
    target_url = promoPill?.target_url ?? ""
}
ToraLytc
  • 50
  • 5
  • And what's your current code doing? You want to open a WKWebView? Or open Safari? – Larme Feb 18 '22 at 09:59
  • @Larme I want to openWKWebView – ToraLytc Feb 18 '22 at 10:35
  • Does this answer your question? [How to load URL on WKWebView?](https://stackoverflow.com/questions/49628954/how-to-load-url-on-wkwebview) – Larme Feb 18 '22 at 11:48
  • @Larme It might work, but it's not what I'm looking for. I am trying to click on the image that is in a cell to open the link, this link comes from remoteconfig – ToraLytc Feb 18 '22 at 13:25
  • 1
    It's unclear. I gave you a related question with answer to open a link into a WKWebView. It's up to you to adapt it from `target_url = ` and use it, no? What's your issue? – Larme Feb 18 '22 at 13:28

1 Answers1

1

Maybe this link can help you

You have to do something like this ->

let myURL = URL(string:"https://www.apple.com")
    let myRequest = URLRequest(url: myURL!)
    webView.load(myRequest)