Skip to content
Titanium SDK
Version12.5.1

You are reading 12.5.1. See this page in 13.4.1.

Titanium.UI.iPad.Popover

viewiPadmacOSsince iPad 1.2.0, macOS 9.2.0

Extends Titanium.UI.ViewTitanium.Proxy

A Popover is used to manage the presentation of content in a popover.

A popover is created using the Titanium.UI.iPad.createPopover method or <Popover> Alloy element.

Popovers are used to present information temporarily, but in a way that does not take over the entire screen in the way that a modal view does. The popover content is layered on top of the existing content in a special type of window. The popover remains visible until the user taps outside of the popover window or it is explicitly dismissed.

Do not add top-level view containers, such as a SplitWindow or TabGroup, to a popover. Adding top-level view containers may have unintended side effects. See the contentView property for more information.

Examples

Simple Popover with a Title and Right Button

In this example, we create a simple popover and position it near the button.

var win = Ti.UI.createWindow({backgroundColor: 'white'});

var button = Ti.UI.createButton({title: 'Open Popover!'});
button.addEventListener('click', function(e){
    popover.show({ view: button });
})
win.add(button);

var rightButton = Ti.UI.createButton({title: 'Robin'});
rightButton.addEventListener('click', function(e){
    alert("But green's the color of spring.");
});

var contentWindow = Ti.UI.createWindow({
    rightNavButton: rightButton,
    title: 'Kermit'
});
contentWindow.add(Ti.UI.createLabel({text: "It's not easy being green."}));

var popover = Ti.UI.iPad.createPopover({
    backgroundColor: 'green',
    contentView: Ti.UI.createNavigationWindow({
        width: 250,
        height: 100,
        window: contentWindow
    })
});

win.open();

Alloy XML Markup

Previous example as an Alloy project.

app/views/index.xml:

<Alloy>
    <Window>
        <Button id="button" onClick="openPopover">Open Popover!</Button>
    </Window>
</Alloy>

app/controllers/index.js:

function openPopover() {
    var popover = Alloy.createController('popover').getView();
    popover.show({view:$.button});
};

$.index.open();

app/views/popover.xml:

<Alloy>
    <Popover backgroundColor='green'>
        <ContentView>
            <NavigationWindow height='100' width='250'>
                <Window title='Kermit'>
                    <RightNavButton onClick="showAlert" title="Robin" />
                    <Label>It's not easy being green.</Label>
                </Window>
            </NavigationWindow>
        </ContentView>
    </Popover>
</Alloy>

app/controllers/popover.js:

function showAlert(e) {
    alert('But green is the color of spring.');
};

// Prior to Alloy 1.1.0, the rightNavButton property was set in the controller.
// var button = Ti.UI.createButton({title: 'Robin'});
// button.addEventListener('click', showAlert);
// $.popover.rightNavButton = button;

Properties 13

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

backgroundColor

since 5.2.0

Sets the background color of the popover.

It is recommended to set this property to colorize the whole popover instead of only its content view.

Default: undefined (behaves as transparent)

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

View to use for the popover content. Must be set before calling the show() method.

Set this property to any Titanium.UI.View object, including a Titanium.UI.Window or Titanium.UI.NavigationWindow object.

This property does not support the Titanium.UI.iOS.SplitWindow or Titanium.UI.TabGroup objects.

When this property is set to a valid object, the popover does not include the navigation controller unless it is set to a Titanium.UI.NavigationWindow object.

In an Alloy application, you can specify this property as a <ContentView> child element of the <Popover> element:

<Alloy>
    <Popover>
        <ContentView>
            <Window title="Popover">
                <Label>Popover!</Label>
            </Window>
        </ContentView>
    </Popover>
</Alloy>

Passthrough views to use when the popover is shown.

Specify view objects that the user can interact with while the popover is open. While interacting with these view, the popover will not be dismissed.

rotation

NumberiPadsince Android 5.4.0, iPhone 12.3.0, iPad 12.3.0

Inherited from Titanium.UI.View

Clockwise 2D rotation of the view in degrees.

tooltip

Stringsince 12.1.0iOS 15.0+

Inherited from Titanium.UI.View

The default text to display in the control's tooltip.

Methods 9

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

getViewById

since 6.1.0

Inherited from Titanium.UI.View

Returns the matching view of a given view ID.

Parameters
ParametersTypeDescription
idString

The ID of the view that should be returned. Use the id property in your views to enable it for indexing in this method.

Hides the popover.

Parameters
ParametersTypeDescription
options?AnimatedOptions

Display properties to use when hiding the popover. Note that the default here is equivalent to passing in { animated: false }

insertAt

since 3.3.0

Inherited from Titanium.UI.View

Inserts a view at the specified position in the children array.

Parameters
ParametersTypeDescription
paramsViewPositionOptions

Pass an object that specifies the view to insert and optionally at which position (defaults to end)

2 fields
position? Number

Position in the children array of the view element to replace.

view Titanium.UI.View

View to insert. Required.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Displays the popover.

Parameters
ParametersTypeDescription
optionsShowPopoverParams

Display properties to use when displaying the popover. Note that the default here is to be animated.

3 fields
animated? Boolean

Indicates whether to animate showing the popover.

rect? Dimension

Sets the arrow position of the popover relative to the attached view object's dimensions when showing the popover.

view Titanium.UI.View

Attaches the popover to the specified view when showing the popover.

Events 1

Fired when the popover is hidden.