Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>A view becomes modal when it is displayed using presentModalViewController:animated. You can pass along the model to be edited before presenting the modal view.</p> <pre><code>DetailViewController dvc = ...; dvc.model = model; dvc.delegate = self; // if you want to use a delegate pattern. [self presentModalViewController:dvc animated:YES]; </code></pre> <p>Since the model you want to edit is available in the modal view controller you can set the values in viewDidLoad. There is no databinding available on the iOS platform which means you have to updated the view and your model manually.</p> <pre><code>- (void)viewDidLoad { [super viewDidLoad]; self.someTextField.text = self.model.someText; } </code></pre> <p>What you need to consider when working with a modal view is that you must provide a way to dismiss it. E.g. by having a navigation bar on top with Cancel and Save buttons. Dismissing a modal view controller is done using:</p> <pre><code>[self dismissModalViewControllerAnimated:YES]; </code></pre> <p>It is possible to dismiss the modal view from within the modal view controller but that also means that such a modal controller must be able to save the model in question. I would personally use a callback to the presenting controller letting it know wether to save or cancel as well as handling the dismissing of the modal view. This can be done using a delegate pattern. So when the user taps Save you can update the model and then notify the delegate.</p> <pre><code>- (IBAction)save:(id)sender { self.model.someText = self.someTextField.text; [self.delegate detailViewControllerDidSave:self]; } </code></pre> <p>And in the presenter have a method like:</p> <pre><code>-(void)detailViewControllerDidSave:(DetailViewController *)controller { // save the model [self dismissModalViewControllerAnimated:YES]; } </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload