AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |
Back to Blog
Xcode 12 storyboard12/15/2023 ![]() ![]() Any model data, like our Book, has to be an optional property of the destination view controller. We call instantiateViewController(withIdentifier:) on the storyboard and get back an initialized view controller. This suffers from some of the same problems as the segue. The showPreview method instantiates the view controller from the storyboard, configures and then presents it. In Xcode 10 and iOS 12, we did that with prepare(for:sender) in the source view private func showPreview ( _ sender : UIButton ) To make this segue useful, we need to pass the model data (in this case a Book) from the source to the destination view controller. ![]() To complete the configuration of the segue you must add a unique identifier in the attributes inspector: Using a storyboard, you create this transition (segue) by control-dragging from the button to the destination view controller. The BookController on the left has a button which, when tapped, transitions to the PreviewController on the right to show a preview of the book. Let’s suppose I’m using storyboards to segue between two view controllers: Note: See Using with Tab Bar Controllers if you’re trying to create a segue action for a tab bar (or navigation) controller relationship segue. If you’re not a fan of storyboards this post is unlikely to change your mind but I’m still happy to see them get better. With the rise of SwiftUI it’s easy to miss that Apple improved storyboards back in Xcode 11 and iOS 13. ![]()
0 Comments
Read More
Leave a Reply. |