Disable one of the Tabs

I have a screenlayout which is set to content Tabs.
It has 3 tabs, but sometimes one of these tabs hase no function.

Is it possible to disable or remove and add it again during runtime?

Maybe this will help? https://forum.xojo.com/4716-disable-a-tab/0

Use this method (put in a module since is an extension)
Then call it as:
self.tabItemEnable(1)=false

Sub tabItemEnable(extends view as iOSView, index as integer, assigns value as Boolean)
  dim tb as iOSTabBar=view.ParentTabBar
  if tb is nil then Return
  dim h as ptr=tb.ViewControllerHandle
  
  Declare Function tabbar_ lib "UIKit" selector "tabBar"(o as Ptr) as Ptr
  dim tabbar as Ptr=tabbar_(h)
  
  declare Function items_ lib "UIKit" selector "items"(o as Ptr) as Ptr
  dim items as Ptr=items_(tabbar)
  
  Declare Function count_ lib "foundation" selector "count"(o as Ptr) as Integer
  dim count as integer=count_(items)
  if index<count then
    Declare Function objAtIndex lib "foundation" selector "objectAtIndex:"(o as Ptr, idx as Integer) as Ptr
    dim item as Ptr=objAtIndex(items,index)
    
    Declare sub setEnabled lib "UIKit" selector "setEnabled:"(o as Ptr, v as Boolean)
    setEnabled(item, value)
  end if
 End Sub

Hey Antonio…while you’ve got tabs on your mind…I don’t suppose you have a declare to add a banner to a tab? You know, one of those red dots with a number in it for notifications? I’d like to notify my users when they have new data in one of my tabs. :slight_smile:

Actually I think I’ve answered my own question. Changing value to a text parameter and replacing the last call to setEnabled with this code seems to work for setting the tab banner:

      declare sub setBadgeValue lib "UIKit" selector "setBadgeValue:" (o as ptr, value as cfstringref)
      setBadgeValue item, value

Yes, now the module can be named tabBarExtension :wink: