I have a today widget for my app which has a UITableView
. Whenever a user taps on a row, I want to open up the main iOS app, navigate to the UIViewController
with the UITableView
., and then select the coresponding cell.
I know to open the app, I would do something like this:
let url = URL(string: "ProjectName://")
extensionContext?.open(url!, completionHandler: nil)
and to select the row, I would do this:
tableView.selectRowAtIndexPath(index, animated: true, scrollPosition: UITableViewScrollPosition.middle)
How would I do this all together from the Today Widget, though?
Conver your index as string and append with your custom url scheme
ProjectName://indexPath.row as string
finally based on index
ProjectName://1 ProjectName://2
Then redirect to your main app using with append values
It will call your main app application delegate, there you can get your index by converting back to Int
In your viewcontroller observe it and convert it to Int
In viewDidLoad
Then add this method