eggswift / ESTabBarController

:octocat: ESTabBarController is a Swift model for customize UI, badge and adding animation to tabbar items. Support lottie!
MIT License
5.18k stars 581 forks source link

Can't run the example project on simulator #203

Closed DKPham closed 5 years ago

DKPham commented 5 years ago

I download the example project but can't run it. It just said "Build Succeed" but it doesn't launch into simulator or device. Please help

HelloHchen commented 5 years ago

When you meet mistakes,You must provide a screenshot of the error.

DKPham commented 5 years ago

Sorry. Here is the screenshot. I created another project and get the code from the example project. I want to customize the middle tab bar item to have big circle like in the demo. But it doesn't work. Simulator Screen Shot - iPhone Xs Max - 2019-07-27 at 14 30 21

And here is my code: import UIKit import ESTabBarController_swift

class BaseTabBarController : ESTabBarController, UITabBarControllerDelegate {

override func viewDidLoad() {
    super.viewDidLoad()
    setupTabBarViewController()
}

func setupTabBarViewController() {
    self.delegate = delegate
    self.title = "Irregularity"
    self.tabBar.shadowImage = UIImage(named: "transparent")
    self.tabBar.backgroundImage = UIImage(named: "background_dark")
    self.shouldHijackHandler = {
        tabbarController, viewController, index in
        if index == 2 {
            return true
        }
        return false
    }
    self.didHijackHandler = {
        [weak tabBarController] tabbarController, viewController, index in

        DispatchQueue.main.asyncAfter(deadline: .now() + 0.2) {
            let alertController = UIAlertController.init(title: nil, message: nil, preferredStyle: .actionSheet)
            let takePhotoAction = UIAlertAction(title: "Take a photo", style: .default, handler: nil)
            alertController.addAction(takePhotoAction)
            let selectFromAlbumAction = UIAlertAction(title: "Select from album", style: .default, handler: nil)
            alertController.addAction(selectFromAlbumAction)
            let cancelAction = UIAlertAction(title: "Cancel", style: .cancel, handler: nil)
            alertController.addAction(cancelAction)
            self.present(alertController, animated: true, completion: nil)
        }
    }

    let v1 = ExampleViewController()
    let v2 = ExampleViewController()
    let v3 = ExampleViewController()
    let v4 = ExampleViewController()
    let v5 = ExampleViewController()

    v1.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Home", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
    v2.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Find", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
    v3.tabBarItem = ESTabBarItem.init(ExampleIrregularityContentView(), title: nil, image: UIImage(named: "photo_verybig"), selectedImage: UIImage(named: "photo_verybig"))
    v4.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Favor", image: UIImage(named: "favor"), selectedImage: UIImage(named: "favor_1"))
    v5.tabBarItem = ESTabBarItem.init(ExampleIrregularityBasicContentView(), title: "Me", image: UIImage(named: "me"), selectedImage: UIImage(named: "me_1"))

    viewControllers = [v1, v2, v3, v4, v5]
}

}

HelloHchen commented 5 years ago

.......... There's a big photo in the demo, so you can look it up, or you can make a big icon

HelloHchen commented 5 years ago

When I first used it, I also encountered the same mistake as you. The reason is as follows: there is something wrong with the size of your icon. You can check the icon in the demo of the author

DKPham commented 5 years ago

I used all the assets that is provided by the example project. The big circle for middle item still don't show up...I can send you the project to check it

HelloHchen commented 5 years ago

I've seen icon size problems before, but I haven't seen you......

DKPham commented 5 years ago

Can i send you my project? please help me if you know how to fix this.

HelloHchen commented 5 years ago

My email is hellohchen@163.com, you can send it to the email

DKPham commented 5 years ago

Thank you so much. I'm sending you right now. Have you receive it?

HelloHchen commented 5 years ago
image

I find you are copying a little less code, TabBar needs to refresh the layout, to implement method: override func updateLayout()

DKPham commented 5 years ago

Thank you. I put this code in ExampleIrregularityContentView class and it work. Again. Thank you so much for helping

HelloHchen commented 5 years ago

It's nothing.

DKPham commented 5 years ago

I owed you big one. Cause i have been stuck with this problem for like a week. I'm so happy that it work now.

HelloHchen commented 5 years ago

What is your xcode version? When I was at xcode10.2.1, pop had animation, but in xode10.3, pop did not have animation but instead displayed directly, and controller set hidesbottombarwhenput = true