Note that there are some explanatory texts on larger screens.

plurals
  1. PODelegation and dismissal of a view controller
    primarykey
    data
    text
    <p>I'm doing an app that has a UITableViewController populated with a list of products. Each row segues to a UIViewController that presents the details of the product in the row. Now since tapping on each row and going back to see the details of the next product might be too tedious for the user, we decide to add this feature: when a user swipes on the UIViewController of a product, then the UIViewController with the details for the next product is pushed.</p> <p>But, as of now, I'm not sure of the best way to implement this. I'm tempted to pass the array of products to the UIViewController so that the swiping is achieved but this will be a violation of the MVC framework,right? Views cannot own the data they're presenting. The product details UIViewController should only know about the specific product that's passed to it, not the rest, right?</p> <p>I think this can be accomplished using delegation but I'm not sure how. Can anybody help me? Thanks!</p> <p>EDIT: Rob Mayoff's code was really helpful so I decided to implement it. But for the meantime, instead of implementing a swipe, I'll just use a simple round rect button to call the functions.</p> <pre><code>- (IBAction)showNextProduct:(id)sender { [self.productsTVC goToProductAtIndex:self.productIndex + 1]; } - (IBAction)showPriorProduct:(id)sender { [self.productsTVC goToProductAtIndex:self.productIndex - 1]; } </code></pre> <p>But every time I click any of the buttons, my app crashes with the message: <code>Finishing up a navigation transition in an unexpected state. Navigation Bar subview tree might get corrupted. Unbalanced calls to begin/end appearance transitions for &lt;ProductDetailsViewController: 0x6e510c0&gt;.</code></p>
    singulars
    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. This table or related slice is empty.
    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