Giter Site home page Giter Site logo

Unable to set selectedIndex about sotabbar HOT 7 OPEN

stwie111 avatar stwie111 commented on May 23, 2024 1
Unable to set selectedIndex

from sotabbar.

Comments (7)

Sandysgit avatar Sandysgit commented on May 23, 2024 1

I also tried changing in

class SOTabBar: UIView

    internal var viewControllers = [UIViewController]() {
    didSet {
        drawTabs()
        guard !viewControllers.isEmpty else { return }
        drawConstraint()
        layoutIfNeeded()
        didSelectTab(index: 2)
    }

}

from sotabbar.

kaigothe avatar kaigothe commented on May 23, 2024 1

My solution is, copy the 4 swift files form Pod in your Project and delete the pod. After that you can modify the didSelectTab(index: 1) in public class SOTabBar: UIView.

from sotabbar.

stwie111 avatar stwie111 commented on May 23, 2024

It would be great if there is a function to change the selectedTab from any of the child class.

from sotabbar.

Ahmadalsofi avatar Ahmadalsofi commented on May 23, 2024

Hi @kaigothe, did you find the solution if so, you can push it to the repo and we are happy to have you with us as a contributor .

from sotabbar.

Jayant-georadius avatar Jayant-georadius commented on May 23, 2024

Any solution for this??

from sotabbar.

MeetBudheliya avatar MeetBudheliya commented on May 23, 2024

My solution is, copy the 4 swift files form Pod in your Project and delete the pod. After that you can modify the didSelectTab(index: 1) in public class SOTabBar: UIView.

@kaigothe Thanks, it's working...

from sotabbar.

khushalhoch23 avatar khushalhoch23 commented on May 23, 2024

Hi @kaigothe, did you find the solution if so, you can push it to the repo and we are happy to have you with us as a contributor .

I have solution for above issue, follow the steps.

Line No : 137 , Class SOTabBar

func didSelectTab(index: Int) {
        if index + 1 == selectedIndex {return}
        animateTitle(index: index)
 
        previousSelectedIndex = selectedIndex
        selectedIndex  = index + 1
        
        delegate?.tabBar(self, didSelectTabAt: index)
        animateCircle(with: circlePath)
        animateImage()
        
        guard let image = self.viewControllers[index].tabBarItem.selectedImage else {
            fatalError("You should insert selected image to all View Controllers")
        }
        self.tabSelectedImageView.image = image
    }

Step 2: class SOTabBarController, set below function at line no : 77

func preSelectedIndex(index: Int){
        self.tabBar.didSelectTab(index: index)
    }

Step 3: Call the function from your Tabbar class

class UTabbarVC: SOTabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        
        self.delegate = self
// your VC setup here
...
// set here you want to selected index
preSelectedIndex(index: 1)
      }
}

from sotabbar.

Related Issues (19)

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.