【问题标题】:Adding page curl animation to view when button is tapped on Appcelerator.Titanium在 Appcelerator.Titanium 上点击按钮时添加页面卷曲动画以查看
【发布时间】:2012-11-27 14:22:15
【问题描述】:

我是 appcelerator.titanium 的新手。我从今天开始开发。

我的问题是, 我想在我的一个视图上点击按钮时显示页面卷曲过渡效果。

我使用以下代码来执行此操作。但是应用程序崩溃了。我在 SO 和钛文档中进行了很多搜索。但找不到解决办法。

//This function returns a window

function ApplicationWindow()
{
    //load component dependencies
    var FirstView = require('ui/common/FirstView');

    //create component instance
    var self = Ti.UI.createWindow({
        backgroundColor:'#ffffff'
    });

    //construct UI
    var firstView = new FirstView();
    self.add(firstView);

    //Adding button for displaying view 2
    var button1 = Ti.UI.createButton({
        height  : '50',
        width   : '50%',
        top     : '70%',
        title : 'Add Child'
    });

    //Adding event listner for button
    button1.addEventListener('click',function(e){
        var view = createView();
        win.add(view);
    });
    self.add(button1);

    //creating second view
    function createView()
    {
        var view = Ti.UI.createView({
            backgroundColor : '#aabbcc'
        });

            //creating button for view 2
        var button2 = Ti.UI.createButton({
        height  : '50',
        width   : '50%',
        top     : '70%',
        title   : 'Show Curl'
    });

    //Adding event listner for button
    button2.addEventListener('click',function(e)
    {
            //creating animation
        var animation = Titanium.UI.createAnimation({
        transition :  Ti.UI.iPhone.AnimationStyle.CURL_UP
            });
        animation.backgroundColor = 'black';
        animation.duration = 1000;
        var animationHandler = function() {
             animation.removeEventListener('complete',animationHandler);
             animation.backgroundColor = 'orange';
             view.animate(animation);
        };
        animation.delay = 5000
        animation.addEventListener('complete',animationHandler);
        view.animate(animation);
     });

     view.add(button2);
     return view;
    }
    return self;
}

//creating window and opening
var win = ApplicationWindow();
win.open();

提前致谢

【问题讨论】:

    标签: iphone animation titanium appcelerator page-curl


    【解决方案1】:

    改用这个模块:http://support.appcelerator.com/kb/119/tickets

    一切都为你准备好了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-03-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2020-07-31
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多