Home > Net >  How to switch to another screen by clicking on a custom image that is inside a table cell?
How to switch to another screen by clicking on a custom image that is inside a table cell?

Time:02-01

I don't have enough skills in iOS development that's why I need your help. Could you please to describe me how can i switch to another screen by clicking on a custom image that is inside a table cell? I am building an application based on MVC architecture, all my part of codes are divided to different files. I have a table which contains a certain number of cells. Each cell has a View and inside its content. One of the contents is a small picture when it clicked it should move to another screen. How can I realize it? I am so sorry I can't share you the parts of codes. Cause it is commercial project. I want to know the implementation principles in this case. I don't use (No - Storyboard), making an app only programmatically. I would be very grateful to you for your help.

CodePudding user response:

There are 2 ways of handling it

  1. Custom Cell:
  • Custom Cell will have the action handler
  • Delegates the call to Table View Controller with meta data
  • Present another screen from Table View Controller
  1. Table View Delegate Method
  • optional func tableView(_ tableView: UITableView,didSelectRowAt indexPath: IndexPath)

  • Based on the index check we can read the data from the datasource

  • Present new screen from the table view controller

CodePudding user response:

Try this

    var body: some View {
        Link("Show example", destination: URL(string: "https://www.example.com")!) // 1 
    }
}
  • Related