Comments (5)
I'll take a look at your issue tomorrow. I'll commit a fix or suggest a workaround.
from dropdownmenukit.
I came to a solution/workaround with the following code in my implementation:
func prepareNavigationBarMenuTitleView() -> String {
// Both title label and image view are fixed horizontally inside title
// view, UIKit is responsible to center title view in the navigation bar.
// We want to ensure the space between title and image remains constant,
// even when title view is moved to remain centered (but never resized).
titleView = DropDownTitleView(frame: CGRect(x: 0, y: 0, width: 280, height: 40))
titleView.addTarget(self,
action: #selector(DocumentViewController.willToggleNavigationBarMenu(_:)),
for: .touchUpInside)
titleView.addTarget(self,
action: #selector(DocumentViewController.didToggleNavigationBarMenu(_:)),
for: .valueChanged)
titleView.titleLabel.textAlignment = .left
titleView.titleLabel.textColor = UIColor.black
// changes I had to make
titleView.titleLabel.numberOfLines = 2
titleView.frame = CGRect(x: 0, y: 0, width: 280, height: 40)
titleView.titleLabel.frame = CGRect(x: 0, y: 0, width: 280, height: 40)
titleView.titleLabel.adjustsFontSizeToFitWidth = true
// Had to change the titleView.title to titleView.titleLable.text
titleView.titleLabel.text = currentNode.title
navigationItem.titleView = titleView
return titleView.title!
}
from dropdownmenukit.
Thanks for the detailed workaround explanation.
I committed a fix that should solve your issue without any workarounds. Let me know if this works for you.
DropDownTitleView
is now automatically resized to match the space available in the navigation bar. This takes in account left and right items. Finally DropDownTitleView.layoutSubviews()
now takes care to center the title and arrow icon properly. If the title is too long, it's also shrunk down and cut automatically according to the ellipsis rule set on DropDownTitleView.titleLabel
.
As a side effect, you don't need to pass a frame when initializing DropDownMenuView
anymore.
from dropdownmenukit.
@qmathe I tried the commit version, but still did not work for me entirely. It would display the title correctly if it's too long but if I choose a title from the drop down menu it would break it and not present it correctly. So unfortunately i had to revert back to the workaround that I commented above.
from dropdownmenukit.
I tried to reproduce the issue you describe with DropDownMenuExample, but I couldn't. I added a left and right item in the navigation bar and I also used very long titles for both "Large" and "Small". However switching between the two titles with the menu appears to work fine. Rotating to Landscape seems to behave correctly too.
If you have any other details that can help me to better understand your issue, let me know. Could you also try to reproduce your app issue by changing DropDownMenuExample code? If you manage to do so, please send me the diff.
from dropdownmenukit.
Related Issues (20)
- Title view collapses on the size of the first item. HOT 5
- Use in Objective-C code? HOT 3
- Inheritance is forbidden HOT 4
- How can I change the color of drop image or up image? HOT 2
- Centering text + image HOT 6
- Drop Down Menu does not work in a popup HOT 6
- The Dropdownmenu won't scroll when too many items HOT 9
- DropDown doesn't work on iOS 11 device HOT 5
- Menu and container not released HOT 2
- Check for empty cells is missing from pod install version in DropDownMenu class HOT 2
- Creating Sections HOT 1
- Broken cocoapods HOT 1
- Feature request - overlay view in outer view controller HOT 2
- UIViewAnimationOptions' has been renamed to 'UIView.AnimationOptions' HOT 2
- issue when working with MBProgressHUD HOT 2
- Please provide support for Swift Package Manager HOT 1
- Do you have an example code for the 'sort' drop down you show in the screen shot? HOT 2
- Error retrieving icon from bundle HOT 1
- Table view not filled HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from dropdownmenukit.