当我点击图片时,我想转到 URL
When I tap the image I want to go to the URL
我正在尝试,当我按下图像时它会将我带到 link
我有这个:
class CoverPillCell: TableViewCell {
@IBOutlet weak var imagePill: UIImageView!
@IBOutlet weak var imagenButton: UIButton!
这包含稍后在加载函数中调用 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)
}
在 IBAction 中,我尝试这样做:
@IBAction func tapPill(_ sender: UIButton) {
let promoPill = getPromoPill()
target_url = promoPill?.target_url ?? ""
}
也许thislink可以帮到你
你必须这样做 ->
let myURL = URL(string:"https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)
我正在尝试,当我按下图像时它会将我带到 link
我有这个:
class CoverPillCell: TableViewCell {
@IBOutlet weak var imagePill: UIImageView!
@IBOutlet weak var imagenButton: UIButton!
这包含稍后在加载函数中调用 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)
}
在 IBAction 中,我尝试这样做:
@IBAction func tapPill(_ sender: UIButton) {
let promoPill = getPromoPill()
target_url = promoPill?.target_url ?? ""
}
也许thislink可以帮到你
你必须这样做 ->
let myURL = URL(string:"https://www.apple.com")
let myRequest = URLRequest(url: myURL!)
webView.load(myRequest)