I'm using Material for just few of the components like buttons and the menu, but after bashing my head for two days I've notice that the reason my UINavigationController setup doesn't work is because Material is overriding it, even if I don't use it.
My current options is either use Material's NavigationController instead (which I really don't want be to forced to do) or to remove the framework which I also don't want to do since I really like it.
Another option is to try and fix it my self, the question is this behavior is normal or intended?
What part does it override that is creating the conflict?
Also what version are you using?
It overrides UINavigationItem.
and I'm using the latest one.
Just to point out, I'm using the framework and not as pod since while using the Pod version none of the Icons and other assets are loading (which is another issue, unrelated)
When you say latest, do you mean development or master? Also, what is the actual issue. You will need to share an error log, code that is not working, or further describe. :)
I've cloned it from master branch.
There's no error to share.. that's why it took me two days to catch what went wrong.
I can tell you what I did and you can reproduce this problem.
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "hello world"
}
import UIKit
import Material
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
self.navigationItem.title = "Hello"
}
}
From what I've noticed, as you Import Material, when ever you access "self.navigationItem" it goes to Material's NavigationItem.swift - UINavigationItem extension, and since you clearly override the variables there, the super class never get called, hence, the problem.
Got it :) I agree, there needs to be a better solution. I will play with it today and tomorrow and most likely push something within then. Thanks for sharing this.
Happy to obligee :-). Thank you for the awesome framework.
Didn't forget about this... going to think about a better solution today. Sorry, was busy in the past week. Thank you!
@shshalom Inside your controller you should not be using self.navigationItem.title. You should be using self.title = "Your title"
Take a look here: http://stackoverflow.com/questions/960316/self-title-vs-self-navigationitem-title
Cheers
I know, but what about adding buttons, icons or any other Object to the navigation controller? the title was the simplest example to demonstrate the problem, besides that there's no way to set a native navigation controller while Material is imported to the same controller.
Why not create a fallback to the native Navigation Item if Material Navigation controller is not in use?
I am going to have to disagree. Material doesn't override any of the UINavigationController or UINavigationBar behaviours, especially when adding buttons. You will only face conflicts if you use the Material NavigationController and Material NavigationBar, which use a separate API for adding controls. So if your issue is that you want to use the default API for the UINavigationController, then you will need to opt out of using Material's. After Adam's point about the self.title, it is clear that using navigationItem.title is actually a second best approach.
If you can suggest a mechanism or fallback that can improve the situation that would be helpful, and a PR would be appreciated. Otherwise for now I am closing this issue and will think of ways to not conflict with the navigationItem.title property.
Also, one more idea for you, is that in Material 2, which is the development branch, it is possible to add the shadow effect and colors to any UIView, so this would actually help you achieve the look and feel of Material and still use the default UINavigationController. If you would like help in achieving this, please let us know.
All the best :)
I will take a look. thank you. 馃憤
Most helpful comment
Happy to obligee :-). Thank you for the awesome framework.