Skip to content

UITabBarControllerEvent ​

UITabBarControllerEvent represents the user selecting a page on the tab bar.

The tabselect event of UITabBarController is this class, and viewController is the page selected. It isn't fired when code changes the selected page.

Inheritance: Event → UITabBarControllerEvent

Constructor ​

UITabBarControllerEvent()

Creates a UITabBarControllerEvent. The runtime creates one itself when it fires the events below; app code can use it to build an event object and fire it with dispatchEvent() to try out a listener.

Instance properties ​

Also inherits the properties of Event; the most commonly used are type and target. The properties below are read-only; assigning to them throws TypeError.

PropertyDescription
viewController read-onlyThe page the user selected

These properties live on the prototype, not on the event object itself: Object.keys(event) and { ...event } don't include them, so read them one by one. See Events with fields.

Events that use this class ​

ObjectEvents
UITabBarControllertabselect

It can't be canceled: cancelable is false. By the time it is fired, the switch is already done, so it can't keep the user from switching.

Examples ​

js
const tabs = new UITabBarController();
tabs.addEventListener('tabselect', (e) => {
  console.log(e instanceof UITabBarControllerEvent, e.viewController === tabs.selectedViewController);
});

Effect: when the user taps a tab to switch, prints true true.

Corresponding iOS API ​

ObjCJS
tabBarController:didSelectViewController:The tabselect event
The viewController parameterevent.viewController

See also ​