Minitour / AZTabBarController

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

Crash with normal use #53

Closed SteynMarnus closed 5 years ago

SteynMarnus commented 5 years ago

Hi there,

I followed the usage tutorial on the ReadMe exactly and my app seems to crash, here is the exception: screenshot 2018-12-10 at 15 50 11

And here is how I use the AZTbarBar:

    var icons = [String]()
    icons.append("document")
    icons.append("group")
    icons.append("compass")
    icons.append("cogwheel")

    var selectedIcons = [String]()
    selectedIcons.append("document_selected")
    selectedIcons.append("group_selected")
    selectedIcons.append("compass_selected")
    selectedIcons.append("cogwheel_selected")

    tabController = AZTabBarController.insert(into: self, withTabIconNames: icons, andSelectedIconNames: selectedIcons)

    let documentsPage = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "documentsViewController")
    let groupPage = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "groupViewController")
    let findPage = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "findViewController")
    let settingsPage = UIStoryboard(name: "Main", bundle: nil).instantiateViewController(withIdentifier: "settingsViewController")

    tabController.setViewController(documentsPage, atIndex: 0)
    tabController.setViewController(groupPage, atIndex: 1)
    tabController.setViewController(findPage, atIndex: 2)
    tabController.setViewController(settingsPage, atIndex: 3)

It seems crash when the AZTabBarController.insert() line is hit

Minitour commented 5 years ago

@SteynMarnus I guess this bug went unnoticed. try setting the selectedColor property before setting a view controller:

//the color of the icon when a menu is selected
tabController.selectedColor = .orange 
Minitour commented 5 years ago

If it still doesn't work try to follow the example see if there is anything you might have missed, either way I will take a look at this when I get the chance: https://github.com/Minitour/AZTabBarController/blob/4cd7e91ee9273d21a32bcfc9ddcc294c6e2bd9d1/AZTabBarController/ViewController.swift#L30

SteynMarnus commented 5 years ago

@SteynMarnus I guess this bug went unnoticed. try setting the selectedColor property before setting a view controller:

//the color of the icon when a menu is selected
tabController.selectedColor = .orange 

That seems to patch it for now. Thank you for getting on this issue 👍

SteynMarnus commented 5 years ago

ViewController.swift.zip Here is my swift files are requested