Versions Compared


  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Change callback to events


  1. Use the  Ti.UI.iOS.forceTouchSupported  to test if the device supports 3D touch.
  2. Create a PreviewContext object using the  Titanium.UI.iOS.createPreviewContext() method. Pass the method a dictionary with the following properties:
    • preview: view object to use as the peeked view.
    • pop: callback function that is invoked when the peeked view is popped.
    • actions: array of PreviewActions or PreviewActionGroup objects to use as the quick actions.
    • contentHeight: height of the preview window. Defaults to fill most of the screen.
  3. Add the peek and pop events to the created preview context to receive updates about the current preview state.
  4. Attach the PreviewContext object to a view. Set the view's previewContext property to the PreviewContext object.


Code Block
function popView() {
if (Ti.UI.iOS.forceTouchSupported) {
    var share = Ti.UI.iOS.createPreviewAction({
        title: "Share",

    share.addEventListener("click", function(e) {
        // Implement share logic here

    $.peekView.previewContext = Ti.UI.iOS.createPreviewContext({
        preview: Alloy.createController('preview').getView(),
        pop: popView(),
        actions: [share]
    $.peekView.previewContext.addEventListener("peek", function() {
        Ti.API.warn("The view was peeked - Update the preview here if you want to");
    $.peekView.previewContext.addEventListener("pop", function() {
        Ti.API.warn("The view was popped - Open the full context here");


For a full example, see