Group Group Group Group Group Group Group Group Group

Multiple UISplitViewController Tutorial | raywenderlich.com


#1

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

#2

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.


#3

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


#4

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.


#5

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


#6

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?


#7

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


#8

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


#9

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


#10

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


#11

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


#12

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


#13

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.