Multiple UISplitViewController Tutorial | raywenderlich.com

This UISplitViewController tutorial shows you how to build an adaptive layout note-taking app using multiple UISplitViewControllers.


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/7212-multiple-uisplitviewcontroller-tutorial

Hi. This looks like a really good tutorial app. From the starter, it doesn’t have the File.swift and Content.swift yet. Do I leave the codegen for both at ‘Class Definition’ and do the ‘Create NSManaged Object subclass …’? I’m not really experienced with Core Data.

@warrenburton Can you please help with this when you get a chance? Thank you - much appreciated! :]

Wait, sorry. It was showing errors that File.swift doesn’t exist but when you run it, it builds successfully. My lack of Core Data knowledge.

Hi Bruce

This is the simplest possible way of using a Core Data model. Xcode will create the files inside the derived data during the build.

You can change this for other projects if you need to by switching Codegen to manual/none

In this app Core Data is used as quick persistence layer so I went with the simple Mode.

Thanks for reading

1 Like

Hi Warren, I suggest putting the sub-splitview on the left instead of the right. Much simpler because requires no need to manually manage collapse or separate. Just need to override traits of the child split in the parent split and forward a few things through the child. I could do a tutorial on it?

@warrenburton Do you have any feedback about this? Thank you - much appreciated! :]

Hi Malcom

That’s not an approach I considered taking when constructing the tutorial. It sounds really interesting if it eliminates the need the pile of delegate code required to reconstruct/deconstruct the navigation stacks during trait change.

Im guessing you mean place the folder list (and file list in sub-secondary) in their own split and place that in the primary while the placeholder/editor remains within the main secondary.

I love it when people come up with new ideas for things. Thanks for the suggestion. Id like to see the result if you ever write the tutorial.

Thanks
Warren

Good evening,
I used this tutorial to attempt to make a triple split view (kinda like apple mail) and ran into an issue when adding a UISearchController to the middle view.
everything loads fine and works on all size devices but when you rotate the device the application crashes. The following is output

2019-02-25 18:26:49.304360-0500 MYAPP[16234:1038669] *** Assertion failure in -[UITableView _addScrollViewScrollObserver:], /BuildRoot/Library/Caches/com.apple.xbs/Sources/UIKitCore_Sim/UIKit-3698.93.8/UIScrollView.m:9243

2019-02-25 18:26:49.319306-0500 MYAPP[16234:1038669] *** Terminating app due to uncaught exception ‘NSInternalInconsistencyException’, reason: ‘ERROR: UIScrollView does not support multiple observers implementing _scrollViewWillEndDraggingWithVelocity:targetContentOffset:’

I am also using a different view for each section not reusing one like the guide.

Not sure how to solve this.
Any help would be great.
Thanks

@warrenburton Can you please help with this when you get a chance? Thank you - much appreciated! :]

Hi Joe

Thanks for the question. What do you mean you are using a different view for each section. You mean you are not recycling views when the traits change from compact to regular?

Do you get the crash when you add the UISearchController or on a rotate event ?

Thanks
Warren

Warren,
I am using three different view controllers for the three sections instead of reusing one (FileList) like the guide does.
The UISearchController is on the middle viewcontroller and works correctly in any orientation as long as it was loaded in that orientation. As soon as you rotate it crashes with the error from above. If you have not yet navigated to the middle viewcontroller rotation works fine. If you navigate to the third view and rotate it still crashes. Navigating from view 1 to 2 and back to 1 rotating still works.
It feels like if the second view is still in the navigation stack it cannot rotate correctly.

Thanks
Joe

Interesting.

I would examine your lifecycles around viewDidAppear or traitCollectionDidChange to see if you’re getting a double installation of the search controller somewhere.

Possibly also try and isolate the issue to see if it’s related to the split setup or something else.

Possibly tagging the relevant deinit method might shed some light on whether you have a retain loop somewhere too.

I have seen this issue before ( not in the tutorial project ) when working with UISearchController . It wasn’t easy to eradicate.

Good luck.

This tutorials is really very helpful. I have done same thing that you did but I am not able to do multiple splitvc. because this code is to complex for me. can you have simple demo of multiple splitvc ? so I can understand like click on cell it add new ViewController ? Thank You … Sir

Hey, it’s working awesome in Xcode 11. I have a quick question. It’s medatory to add UISplitViewController to UIViewController For Multiple SplitViewController .?

Hi Yogesh

Thanks for trying the tutorial. I can’t do special projects as these projects take a long time to create.

If I understand your second post correctly you are asking if its mandatory to add the sub UISplitViewController to a container UIViewController to have multiple splits. I don’t think so. A split view is a collection of UIViewController and a UISplitViewController is-a UIViewController.

Best of luck with your work
Warren

This tutorial is more than six months old so questions are no longer supported at the moment for it. Thank you!