last day (14 days later) » 

4:24 AM
1
A: Toolbar not visible

FahimThe first tab has a navigation controller as the root controller - the second does not. You can select SearchVC in your storyboard and then use the Editor - Embed In - Navigation Controller menu option to add a navigation controller. That might not be how you want your UI. But that would achieve...

 
And how can I make it work?
 
You can select SearchVC in your storyboard and then use the Editor - Embed In - Navigation Controller menu option to add a navigation controller. That might not be how you want your UI. But that would achieve what you want visually ...
 
I found another solution, instead of using the segue I was using didSelectItemAt indexPath and then programmatically instantiating let navController = UINavigationController(rootViewController: readVC). But it works with a modal transition and I want a push transition like the first one.
 
With just the storyboard to go on, and without your code, I can't really tell you what works and what does not :) If you want to post the project, I can take a look and tell you what might work.
 
I tried to embed the SearchVC but it does not work either...
 
4:24 AM
Then, I'm afraid that I'd have to see the working project to figure out what is going on since there could be a number of issues. It's hard to tell from an image since I can't see properties for each view controller or how the segues are connected or how things work in code :)
Hey Giovanni :) How can I help?
 
@Fahim, yes the project is a bit complicated now
I found another solution using didSelectItemAtindexPath
where I instantiate programmatically let navController = UINavigationController(rootViewController: readVC).
 
If that works for you, great :) I just can't comment on things since I don't know what you are doing - I mean in code.
I saw that - you pasted that above.
 
right, but it gives me a modal transition
but I want a push transition
 
The line you gave simply creates the nav controller - I don't see how you do your transition.
 
func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) {
// Instantiate the selected BookVC
let readVC = self.storyboard?.instantiateViewController(withIdentifier: "ReadID") as! ReadVC

// Creating a navigation controller with viewController at the root of the navigation stack.
let navController = UINavigationController(rootViewController: readVC)
navController.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
navController.toolbar.backgroundColor = UIColor.white
but the CATransition() it does not give me the desired push transition I want...
 
4:32 AM
Is the above code is from BreaksVC? If so, why do you create another navigation controller?
 
no it's from EditorVC
 
Because you can either use the segue to ReadVC or simply push a ReadVC instance on to your existing navigation controller ...
 
push a ReadVC instance? what do you mean?
 
Ah ... I was looking at SearchVC and thought it was connected to EditorVC but now I see it's not connected at all .. So EditorVC is not a tab on the tab bar? It's a separate view controller? How do you access it first time?
 
correct
in SearchVC there is a PInterest style segment
which opens to EditorVC and other view controllers
 
4:36 AM
OK, so you launch EditorVC from somewhere in SearchVC. But how is editorVC added to SearchVC? Can you show me the code?
Or rather, how is EditorVC presented from SearchVC?
 
s.valueChange = { index in

switch index {
case 0:
self.add(asChildViewController: self.editorVC)
self.remove(asChildViewController: subjectsVC)
case 1:
subjectsVC.loadStore()
subjectsVC.passedFilename = "1"
subjectsVC.passedSubject = "Health & Physiology"
self.add(asChildViewController: subjectsVC)
self.remove(asChildViewController: self.editorVC)
case 2:
subjectsVC.loadStore()
subjectsVC.passedFilename = "2"
subjectsVC.passedSubject = "Neurobiology"
self.add(asChildViewController: subjectsVC)
like this, the first case is the editorVC
 
OK, can I suggest a few changes?
 
Sure
 
This is going to be a bit complicated so, you might want to create a git branch of something in case I make too many changes for you to revert back easily :)
 
eh eh yes no problem
 
4:39 AM
Basically, you are adding the EditorVC as a child view controller instead of presenting it. I'd suggest you push it on to the SearchVC so that EditorVC makes use of the existing navigation controller on SearchVC.
Of course, then you don't need the extra navigation controller you've added to EditorVC on the storyboard.
Does those two changes make sense to you so far?
 
oh
makes sense.. how can i push it
 
You'd say self.navigationController.pushViewController(editorVC ...) or something along those lines - I can look up the exact syntax. I never remember syntax - I rely on the IDE for that :0
func pushViewController(UIViewController, animated: Bool)
 
yes yes right
 
Now, when you get to the other part where you want to show ReadVC, you again push instead of using presentViewController ...
This way, all the views go on the single navigation controller you have on SearchVC and you will see the navigation bar and tab bar correctly.
 
yes I see
 
4:43 AM
Try it and let me know if it works as you expected or not ...
 
and it should work in the same way with the SubjectsVC that is the one under the case 1:, case 2: ecc ecc
 
Yep. Push all your view controllers on to one single existing navigation controller - makes navigation (and code) much easier :)
 
I should embed the SearchVC in a navigation controller that is equal to the one where BReaksVC is embedded in
 
Exactly :)
 
it is not repetitive code right?
 
4:45 AM
Because your hierarchy is Tab Controller - Navigation Controller for each tab.
 
Correct..
 
Nope, you're doing it exactly right - you have to have a separate navigation controller for each tab in your tab controller
 
Thank you very much, I will try it out
you were extremely helpful
 
Great. And if it does work, please mark my answer as "correct". I'll expand upon it so that it helps others too ...
Happy to help :)
 
of course, I might try it out tomorrow it's getting late :)
have a great night
 
4:47 AM
It's day over here :) But I wish you a great night!
 

last day (14 days later) »