You are reading 12.6.1. See this page in 13.4.1.
Titanium.UI.iPad.Popover
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
Inherited from Titanium.Proxy
The name of the API that this proxy corresponds to.
arrowDirection
NumberIndicates the arrow direction of the popover.
Use this property to indicate the popover arrows to use. You can bitwise-OR the constant values together.
Do not set this property to Titanium.UI.iPad.POPOVER_ARROW_DIRECTION_UNKNOWN.
backgroundColor
since 5.2.0Sets 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)
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>
height
Number | StringInherited from Titanium.UI.View
View height, in platform-specific units.
Inherited from Titanium.UI.View
Adds a horizontal parallax effect to the view
id
StringInherited from Titanium.UI.View
View's identifier.
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.
Inherited from Titanium.UI.View
Clockwise 2D rotation of the view in degrees.
Inherited from Titanium.UI.View
The default text to display in the control's tooltip.
Inherited from Titanium.UI.View
Adds a vertical parallax effect to the view
width
Number | StringInherited from Titanium.UI.View
View's width, in platform-specific units.
Methods 9
Inherited from Titanium.Proxy
Adds the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to invoke when the event is fired. 4 fields
|
applyProperties
since 3.0.0Inherited from Titanium.Proxy
Applies the properties to the proxy.
| Parameters | Type | Description |
|---|---|---|
| props | Dictionary | A dictionary of properties to apply. |
clearMotionEffects
since 8.2.0Inherited from Titanium.UI.View
Removes all previously added motion effects.
Inherited from Titanium.Proxy
Fires a synthesized event to any registered listeners.
| Parameters | Type | Description |
|---|---|---|
| name | String | 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.0Inherited from Titanium.UI.View
Returns the matching view of a given view ID.
| Parameters | Type | Description |
|---|---|---|
| id | String | The ID of the view that should be returned. Use the |
Hides the popover.
| Parameters | Type | Description |
|---|---|---|
| options? | AnimatedOptions | Display properties to use when hiding the popover.
Note that the default here is equivalent to passing in |
insertAt
since 3.3.0Inherited from Titanium.UI.View
Inserts a view at the specified position in the children array.
| Parameters | Type | Description |
|---|---|---|
| params | ViewPositionOptions | Pass an object that specifies the view to insert and optionally at which position (defaults to end) 2 fields
|
Inherited from Titanium.Proxy
Removes the specified callback as an event listener for the named event.
| Parameters | Type | Description |
|---|---|---|
| name | String | Name of the event. |
| callback | Callback<Titanium.Event> | Callback function to remove. Must be the same function passed to 4 fields
|
Displays the popover.
| Parameters | Type | Description |
|---|---|---|
| options | ShowPopoverParams | Display properties to use when displaying the popover. Note that the default here is to be animated. 3 fields
|
Events 1
Fired when the popover is hidden.