Xlpagertabstrip: Can't connect 'containerView' and 'buttonBarView' outlets

Created on 11 Mar 2016  路  15Comments  路  Source: xmartlabs/XLPagerTabStrip

Hi! I'm trying to connect the outlets for containerView and buttonBarView, but this outlets doesn't exists on my class, only on it's parent (BaseButtonBarPagerTabStripViewController). But I can't connect, it just doesn't work.

How can I proceed?

screen shot 2016-03-11 at 2 53 36 pm

question

Most helpful comment

As a workaround in order to make it work as initial view controller i had to...

  • remove initial view controller arrow from storyboard.
  • change my app delegate code as shown below:
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        ..
        let _ = YoutubeExampleViewController(nibName: nil, bundle: nil)

        let sb = UIStoryboard(name: "Storyboard", bundle: nil)
        let tabBarViewController = sb.instantiateViewControllerWithIdentifier("YoutubeControllerId")
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.rootViewController = tabBarViewController
        window?.makeKeyAndVisible()

        return true
    }

All 15 comments

This is because TabsViewController is a generic class and IB does not work with generics.

As a workaround you can change the base class of TabsViewController to ButtonBarPagerTabStripViewController then connect the ButtonBarPagerTabStripViewController outlets then put back your parent generic class (BaseButtonBarPagerTabStripViewController).

You will also have to invoke let _ = TabsViewController(nibName: nil, bundle: nil) from func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool in in order to load the your generic class into objective-c runtime.

Doing that I made Youtube example works in the example app.

Hope it helps you.

Ok, I did what you've said and using ButtonBarPagerTabStripViewController I could connect containerView and buttonBarView (and it's working). Then, I've changed back my TabsViewController to the YouTube example (and followed your advice adding that line on AppDelegate).

But it seems that is rejecting the containerView outlet. Any ideas?

Error Message:

*** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key containerView.'

Have you deleted ..

buttonbarView and containerView properties/outlets from your TabsViewController code. You should connect the base class outlets and not re-declare these properties/outlets in your own class.

?

Yes, I'm doing that. I've connected them from the base class (containerView from PageTabStripViewController and buttonBarView from ButtonBarPagerTabStripViewController)

(And I've deleted the previously connections)

Could you upload a base project so i can take a look..?
I have done this twice and it worked in both.

Is the storyboard view controller Class properly set up ? I'm asking because when you extend from the generic base controller IB does not suggest it when typing.

I can't send you my project, but I can send you the two classes that I'm working.

Here it is:

let _ = TabsViewController(nibName: nil, bundle: nil) must be executed before instantiating the storyboard view controller.

Is TabsViewController the root view controller?

I just tried setting up YoutubeExampleViewController as root view controller and it does not work.

Unknown class _TtC7Example28YoutubeExampleViewController in Interface Builder file.
2016-03-11 18:40:16.299 Example[90438:2865286] *** Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[<UIViewController 0x7fc98a11b500> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key buttonBarView.'

Could you try adding another view controller as a root view controller and navigating to your tab bar view controller in some way ?

Yes, it is!

screen shot 2016-03-11 at 6 42 11 pm

As a workaround in order to make it work as initial view controller i had to...

  • remove initial view controller arrow from storyboard.
  • change my app delegate code as shown below:
    func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
        ..
        let _ = YoutubeExampleViewController(nibName: nil, bundle: nil)

        let sb = UIStoryboard(name: "Storyboard", bundle: nil)
        let tabBarViewController = sb.instantiateViewControllerWithIdentifier("YoutubeControllerId")
        window = UIWindow(frame: UIScreen.mainScreen().bounds)
        window?.rootViewController = tabBarViewController
        window?.makeKeyAndVisible()

        return true
    }

Ok! Now it's working like a charm! Thank you very much @mtnbarreto :)

thank you so much @mtnbarreto . Have been stuck in that thing for 2 hours

How Can I fix the problem if the Youtube Class is child class of TabbarViewController?

@keason I am trying to do this as well because I need customized button cells, any updates? I am able to connect the buttonBarView and containView from sb to my viewController: BaseButtonBarPagerTabStripViewController; but having the KVC error when I tab this tabitem from UITabbar.

@keason I have solved this by applying the workaround from mtnbarreto. Another issue I had is solved after checking #355

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MahmoudTarek picture MahmoudTarek  路  13Comments

Raymond26 picture Raymond26  路  14Comments

miranda-elliott picture miranda-elliott  路  11Comments

ShockUtility picture ShockUtility  路  10Comments

shadowTech827 picture shadowTech827  路  12Comments