Minitour / AZTabBarController

A custom tab bar controller for iOS written in Swift 4.2
MIT License
348 stars 65 forks source link

Don't run didSelectRowAt #60

Closed stechome closed 5 years ago

stechome commented 5 years ago

I included aztabbar in my project. But there is a problem. This problem: I cannot use any function on that page. For example, switch button can not switch on and off. What should I do? So I can't run Tableview's didSelectRowAt function.

    var counter = 0
    var tabController:AZTabBarController!      
    var resultArray:[String] = []

 func tabbar2() {
        var icons = [UIImage]()
        icons.append(#imageLiteral(resourceName: "outlet"))
        icons.append(#imageLiteral(resourceName: "addplus"))
        icons.append(#imageLiteral(resourceName: "clock-alarm"))
        icons.append(#imageLiteral(resourceName: "email-7"))

        var sIcons = [UIImage]()
        sIcons.append(#imageLiteral(resourceName: "homepage"))
        sIcons.append(#imageLiteral(resourceName: "newdevice"))
        sIcons.append(#imageLiteral(resourceName: "menuwatch"))
        sIcons.append(#imageLiteral(resourceName: "contact"))

        //tabController = AZTabBarController.insert(into: self, withTabIconNames: icons)
        tabController = AZTabBarController.insert(into: self, withTabIcons: icons, andSelectedIcons: sIcons)

        //set delegate
        tabController.delegate = self

        //set child controllers

        let color = UIColor(red: 14.0/255, green: 122.0/255, blue: 254.0/255, alpha: 1.0)

        tabController.selectedColor = color

        tabController.highlightColor = color

        tabController.highlightedBackgroundColor = #colorLiteral(red: 0.1803921569, green: 0.8, blue: 0.4431372549, alpha: 1)

        tabController.defaultColor = .lightGray

        //tabController.highlightButton(atIndex: 2)

        tabController.buttonsBackgroundColor = UIColor(red: (247.0/255), green: (247.0/255), blue: (247.0/255), alpha: 1.0)//#colorLiteral(red: 0.2039215686, green: 0.2862745098, blue: 0.368627451, alpha: 1)

        tabController.selectionIndicatorHeight = 0

        tabController.selectionIndicatorColor = color

        tabController.tabBarHeight = 60

        tabController.notificationBadgeAppearance.backgroundColor = .red
        tabController.notificationBadgeAppearance.textColor = .white
        tabController.notificationBadgeAppearance.borderColor = .clear
        tabController.notificationBadgeAppearance.borderWidth = 0.2

    //    tabController.setViewController(ColorSelectorController.instance(), atIndex: 0)

        tabController.setAction(atIndex: 0) {
            let navController = UINavigationController(rootViewController: MainTableViewController())

            self.present(navController, animated: false, completion: {

            })
        }
        tabController.setAction(atIndex: 1) {
            let navController = UINavigationController(rootViewController: NewMainTableViewController())

            self.present(navController, animated: false, completion: {

            })
        }
        tabController.setAction(atIndex: 2) {
            let navController = UINavigationController(rootViewController: TimerViewController())

            self.present(navController, animated: false, completion: {

            })
        }
        tabController.setAction(atIndex: 3) {
            let navController = UINavigationController(rootViewController: ContactViewController())

            self.present(navController, animated: false, completion: {

            })
        }

        tabController.setBadgeText("1", atIndex: 1)

        tabController.animateTabChange = true
        tabController.onlyShowTextForSelectedButtons = false
        tabController.setTitle("Anasayfa", atIndex: 0)
        tabController.setTitle("Cihaz Ekle", atIndex: 1)
        tabController.setTitle("Zamanlayıcı", atIndex: 2)
        tabController.setTitle("İletişim", atIndex: 3)
        tabController.font = UIFont(name: "AvenirNext-Regular", size: 12)

        let container = tabController.buttonsContainer
        container?.layer.shadowOffset = CGSize(width: 0, height: -2)
        container?.layer.shadowRadius = 10
        container?.layer.shadowOpacity = 0.1
        container?.layer.shadowColor = UIColor.black.cgColor

        tabController.setButtonTintColor(color: #colorLiteral(red: 0.8078431487, green: 0.02745098062, blue: 0.3333333433, alpha: 1), atIndex: 0)
        //if you are loading programmatically:
        //let myChildViewController = MainTableViewController()

       // tabController.setViewController(myChildViewController, atIndex: 0)

    }
Minitour commented 5 years ago

Can you please explain what is exactly the issue? Are you trying to access a child view controller from outside? Is the controller not loading? What is the expected output and what are you getting?