New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't connect 'containerView' and 'buttonBarView' outlets #141

Closed
joaohkfaria opened this Issue Mar 11, 2016 · 15 comments

Comments

Projects
None yet
6 participants
@joaohkfaria

joaohkfaria commented Mar 11, 2016

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

@mtnbarreto

This comment has been minimized.

Show comment
Hide comment
@mtnbarreto

mtnbarreto Mar 11, 2016

Member

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.

Member

mtnbarreto commented Mar 11, 2016

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.

@joaohkfaria

This comment has been minimized.

Show comment
Hide comment
@joaohkfaria

joaohkfaria Mar 11, 2016

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: '[<UIViewController 0x7c286420> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key containerView.'

joaohkfaria commented Mar 11, 2016

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: '[<UIViewController 0x7c286420> setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key containerView.'

@mtnbarreto

This comment has been minimized.

Show comment
Hide comment
@mtnbarreto

mtnbarreto Mar 11, 2016

Member

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.

?

Member

mtnbarreto commented Mar 11, 2016

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.

?

@joaohkfaria

This comment has been minimized.

Show comment
Hide comment
@joaohkfaria

joaohkfaria Mar 11, 2016

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)

joaohkfaria commented Mar 11, 2016

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)

@mtnbarreto

This comment has been minimized.

Show comment
Hide comment
@mtnbarreto

mtnbarreto Mar 11, 2016

Member

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.

Member

mtnbarreto commented Mar 11, 2016

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.

@joaohkfaria

This comment has been minimized.

Show comment
Hide comment
@joaohkfaria

joaohkfaria Mar 11, 2016

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

Here it is:

joaohkfaria commented Mar 11, 2016

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

Here it is:

@mtnbarreto

This comment has been minimized.

Show comment
Hide comment
@mtnbarreto

mtnbarreto Mar 11, 2016

Member

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

Is TabsViewController the root view controller?

Member

mtnbarreto commented Mar 11, 2016

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

Is TabsViewController the root view controller?

@mtnbarreto

This comment has been minimized.

Show comment
Hide comment
@mtnbarreto

mtnbarreto Mar 11, 2016

Member

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 ?

Member

mtnbarreto commented Mar 11, 2016

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 ?

@joaohkfaria

This comment has been minimized.

Show comment
Hide comment
@joaohkfaria

joaohkfaria commented Mar 11, 2016

Yes, it is!

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

@mtnbarreto

This comment has been minimized.

Show comment
Hide comment
@mtnbarreto

mtnbarreto Mar 11, 2016

Member

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
    }
Member

mtnbarreto commented Mar 11, 2016

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
    }
@joaohkfaria

This comment has been minimized.

Show comment
Hide comment
@joaohkfaria

joaohkfaria Mar 13, 2016

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

joaohkfaria commented Mar 13, 2016

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

@tin612

This comment has been minimized.

Show comment
Hide comment
@tin612

tin612 Apr 7, 2017

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

tin612 commented Apr 7, 2017

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

@keason

This comment has been minimized.

Show comment
Hide comment
@keason

keason May 17, 2017

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

keason commented May 17, 2017

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

@ZeranLatte

This comment has been minimized.

Show comment
Hide comment
@ZeranLatte

ZeranLatte Aug 18, 2017

@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.

ZeranLatte commented Aug 18, 2017

@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.

@ZeranLatte

This comment has been minimized.

Show comment
Hide comment
@ZeranLatte

ZeranLatte Aug 18, 2017

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

ZeranLatte commented Aug 18, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment