Giter Club home page Giter Club logo

Comments (5)

qmathe avatar qmathe commented on June 14, 2024

I'll take a look at your issue tomorrow. I'll commit a fix or suggest a workaround.

from dropdownmenukit.

ha-hamed avatar ha-hamed commented on June 14, 2024

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!
}

screen shot 2017-05-31 at 10 05 55 am

screen shot 2017-05-31 at 10 06 33 am

from dropdownmenukit.

qmathe avatar qmathe commented on June 14, 2024

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.

ha-hamed avatar ha-hamed commented on June 14, 2024

@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.

qmathe avatar qmathe commented on June 14, 2024

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.

capture d ecran 2017-06-05 a 18 03 24

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.