Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

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".