Changing and removing newTabBar tabs at runtime

Using the sample 2 tabbed sample generated by the sdk

I don’t see a function to do it – and trying to assign a new array to the tabBar created in manilla doesn’t do anything. 

I specifically want different tabors for different scenes (context relevant)

I’ve managed to create a new tabBar in a scene by duplicating the code from main.lua – Does that create a SECOND newTabBar? or can there be only one at any time? If it’s a second one – how do I delete it when I leave the scene?

Thanks

Hi @akiva,

If you want to show a different tab bar in each scene, you should create each one within the scene that it belongs to, not inside main.lua. That way, it will become part of the scene (assuming you insert it into the scene’s view) and it will be managed by Composer.

Take care,

Brent

Hi @akiva,

Well, the first thing you should learn/understand is how Composer manages scenes, and how objects are removed or kept in memory. This guide should help:

https://docs.coronalabs.com/guide/system/composer/index.html

As for removing a tabBar in code, it’s basically just another display object (well, a group of objects, but treated as an object). So you can just remove it via the basic removal code:

https://docs.coronalabs.com/api/type/DisplayObject/removeSelf.html

OR

https://docs.coronalabs.com/api/library/display/remove.html

Brent

Hi @Brent

Thanks. I’d read the guide – I’m still getting up to speed with the SDK/APIs…

I assume I should add the tabBar to the self.view group?

Thanks again

Yes, adding objects to the self.view group makes them part of the scene.

Brent

Hi @akiva,

If you want to show a different tab bar in each scene, you should create each one within the scene that it belongs to, not inside main.lua. That way, it will become part of the scene (assuming you insert it into the scene’s view) and it will be managed by Composer.

Take care,

Brent

Hi @akiva,

Well, the first thing you should learn/understand is how Composer manages scenes, and how objects are removed or kept in memory. This guide should help:

https://docs.coronalabs.com/guide/system/composer/index.html

As for removing a tabBar in code, it’s basically just another display object (well, a group of objects, but treated as an object). So you can just remove it via the basic removal code:

https://docs.coronalabs.com/api/type/DisplayObject/removeSelf.html

OR

https://docs.coronalabs.com/api/library/display/remove.html

Brent

Hi @Brent

Thanks. I’d read the guide – I’m still getting up to speed with the SDK/APIs…

I assume I should add the tabBar to the self.view group?

Thanks again

Yes, adding objects to the self.view group makes them part of the scene.

Brent