Ask Your Question
4

Is it possible to programmatically modify the row in the DetailView of a Swift UISplitView?

asked 2023-03-03 11:00:00 +0000

scrum gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2022-07-14 12:00:00 +0000

david gravatar image

Yes, it is possible to programmatically modify the row in the DetailView of a Swift UISplitView. To do this, you will need to access the DetailView controller and modify its view or data source. Here's an example of how to modify the DetailView controller's label text with a button click from the MasterView controller:

  1. In the MasterView controller, create an IBAction function for the button click:
@IBAction func buttonClicked(_ sender: Any) {
    // Get the DetailView controller
    guard let detailVC = splitViewController?.viewControllers.last as? DetailViewController else {
        return
    }

    // Modify the label text
    detailVC.label.text = "New Text"
}
  1. In the DetailView controller, create an IBOutlet for the label:
@IBOutlet weak var label: UILabel!
  1. Run the app and click the button in the MasterView. The label text in the DetailView should change to "New Text".
edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-03-03 11:00:00 +0000

Seen: 10 times

Last updated: Jul 14 '22