Set UITabBarController created in Interface Builder as delegate

后端 未结 4 1923
北荒
北荒 2021-01-05 08:33

I created my iOS app with Tab Bar template, so here is UITabBarController with bar buttons. An issue is how to set it as delegate. I found at SO that it has to be set progra

4条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-05 09:00

    0 lines of code

    Drag an Object and subclass it

    1. Xcode > Show File Inspector > Custom Class.
    2. Class: TabBarControllerDelegate.

    Set delegate to that Object


    Put your existing code in that Object

    This is the code you already have in your current UITabBarControllerDelegate.

    class TabBarControllerDelegate: NSObject, UITabBarControllerDelegate {
        // Delegate code goes here
    }
    

提交回复
热议问题