I followed along the Widget Code Along part two in my own app. In the tutorial they discussed linking the data on the widget to that in the tableview. When you clicked on the widget it would take you to the linked tableviewcell with swiftUI. In my app, my widget is swiftUI, but my tableview inside my main app is UIKit and Storyboards. How can create the URL link in UIKit like the one in swiftUI?
UIKit doesn’t have a special button or control specifically for links, but you can cause UIKit to open a URL by calling UIApplication.shared.open(<#url#>). For example, you might connect a UIButton to this IBAction:
Or put something like this in a table view delegate:
The method can also take a dictionary of options and a completion handler, but these parameters are optional.
Code Block swift @IBAction func openSupportSite(_ sender: Any) { UIApplication.shared.open(supportSiteURL) }
Or put something like this in a table view delegate:
Code Block swift func tableView(_: UITableView, didSelectRowAt indexPath: IndexPath) { let selectedRowData = rowData[indexPath.row] // rowData is the array of objects you’re displaying UIApplication.shared.open(selectedRowData.url) }
The method can also take a dictionary of options and a completion handler, but these parameters are optional.
Not really what I'm looking for... I'm trying to use the widgetURL api to connect to my UITableView if that makes it clearer.
@iEvanC were you able to figure it out?
Update
I figured out. I ended up using Universal URL, to open my app when the widget is clicked and go to the tableviewcell that correlates to the URL.
I figured out. I ended up using Universal URL, to open my app when the widget is clicked and go to the tableviewcell that correlates to the URL.