Git Product home page Git Product logo

Comments (6)

Pircate avatar Pircate commented on July 16, 2024

Which version are you using?

from eachnavigationbar.

luke-riu avatar luke-riu commented on July 16, 2024

My podlock file shows 1.15.0

from eachnavigationbar.

Pircate avatar Pircate commented on July 16, 2024

Can I have a look at your code?

from eachnavigationbar.

luke-riu avatar luke-riu commented on July 16, 2024

Sure.
Ignore the custom Colour., Fonts. and Image.. These are SwiftGen structs for UIColor, UIFont and UIImage

In my UINavigationController subclass, I have

private func setupNavigationBar() {
    self.navigation.configuration.isEnabled = true
    self.navigation.configuration.titleTextAttributes = [
      .foregroundColor: Colour.text
    ]
    self.navigation.configuration.barTintColor = Colour.layer1
    self.navigation.configuration.isTranslucent = false
    self.navigation.configuration.isHidden = true
    self.navigation.configuration.backItem = UINavigationController
      .Configuration
      .BackItem(style: .image(Image.back),
                tintColor: Colour.text)
    
  }

The homepage has

private fund setupNavigationBar() {
    self.navigation.bar.isHidden = false
    
    self.navigation.bar.prefersLargeTitles = false
    self.navigation.item.largeTitleDisplayMode = .never
    self.navigation.bar.additionalHeight = 20
    
    // acts as a bit of a skirt to keep the label off the bottom of the nav bar
    let navFooter = UIView(frame: CGRect(x: 0, y: 0, width: 100, height: 18))
    navFooter.backgroundColor = Colour.layer1
    self.navigation.bar.additionalView = navFooter
    
     // title
    let label = UILabel(frame: .zero)
    label.text = "Explore"
    label.font = Fonts.h2
    self.navigation.item.leftBarButtonItem = UIBarButtonItem(customView: label)

     // search button
    let imageview = UIImageView()
    imageview.image = Image.search.withRenderingMode(.alwaysTemplate)
    imageview.tintColor = Colour.text
    
    let searchButton = UIButton(type: .custom)
    searchButton.addTarget(buttonTarget, action: buttonSelector, for: .touchUpInside)
    searchButton.addSubview(imageview)
    searchButton.accessibilityIdentifier = "nav_button"
    
   // snapkit constraints
    imageview.snp.makeConstraints { (make) in
      make.width.height.equalTo(24)
      make.left.right.equalToSuperview()
      make.top.bottom.equalToSuperview().inset(10)
    }
    
    self.navigation.item.rightBarButtonItem = UIBarButtonItem(customView: searchButton)
}

Before the next view controller is pushed, I call

trendingViewController.navigationItem.title = "Trending"

then in viewDidLoad(animated:) on that view controller, I call

    self.navigation.bar.prefersLargeTitles = true
    self.navigation.item.largeTitleDisplayMode = .always

Then, my UI tests goes something like this

    let app = XCUIApplication()
    // tap cell to get into view controller
    // test element exists
    app.navigationBars.buttons.element(boundBy: 0).tap() // <-- fails

Thanks

from eachnavigationbar.

Pircate avatar Pircate commented on July 16, 2024
navigation.bar.backBarButtonItem = .init(style: .image(image))

Try using it in trendingViewController

from eachnavigationbar.

luke-riu avatar luke-riu commented on July 16, 2024

Sadly not made any difference. Putting a breakpoint in my test, when I type into the console

po app.navigationBars.buttons

I get the following output

Find: Target Application 'com.my.app'
  Output: {
    Application, pid: 18209, label: 'App'
  }
  ↪︎Find: Descendants matching type NavigationBar
    Output: {
      NavigationBar, {{0.0, 47.0}, {428.0, 96.0}}, identifier: 'Trending'
      NavigationBar, {{0.0, 47.0}, {428.0, 96.0}}, identifier: 'Trending'
    }
    ↪︎Find: Descendants matching type Button
      Output: {
        Button, {{0.0, 47.0}, {55.7, 44.0}}, label: 'Back'
        Button, {{12.0, 47.0}, {36.0, 44.0}}
      }

I'm sure you'll know better than me, but I think it a bit weird there are two buttons, one which says "Back". Either way, when doing either po app.navigationBars.buttons.element(boundBy: 0).isHittable is false for both 0 and 1.
I'm not sure if that's helpful.

from eachnavigationbar.

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.