钛弹出不起作用

时间:2011-09-29 07:24:08

标签: mobile titanium appcelerator appcelerator-mobile popover

我正在尝试使用钛合金中的“Popover”功能。

我进入了厨房,并在我的应用程序中构建了一些代码,但有些代码

我收到了这个错误:

Result of expression 'Ti.UI.iPad' [undefined] is not an object.

我不知道我做错了什么。

这是我的代码:

var RLWindow=Ti.UI.createWindow({backgroundColor:'#700'});

var LBBar=Titanium.UI.createView({height:60,left:0,right:0,top:105,backgroundImage:'Images/toolbar.jpeg'});

var ShowNotes=Ti.UI.createButton({color:'blue',font:{fontSize:20,fontWeight:"bold"},‌​right:10,title:'Today Notes',height:40,width:120});

LBBar.add(ShowNotes);

RLWindow.add(LBBar);
ShowNotes.addEventListener('click',function(e){

    var popover = Ti.UI.iPad.createPopover({ 
        width:300, 
        height:250,
        title:'Test Popover',
        arrowDirection:Ti.UI.iPad.POPOVER_ARROW_DIRECTION_UP
    }); 

    popover.show({
        view:button,
        animated:true
    });

     });

请帮我解决这个问题..

谢谢

2 个答案:

答案 0 :(得分:2)

清除你的build / iphone文件夹。我有时会注意到,当您添加新的平台UI对象时,编译器不会在xcode项目中包含所需的Ti库。

答案 1 :(得分:0)

这仅适用于iPad,而不适用于iPhone。我假设你正在使用它?对于iPhone,你应该使用常规窗口。

话虽如此,什么是按钮?说出这个名字,我猜这是你的问题,因为你需要一个视图。如果我这样做(下面),它似乎对我来说很完美:

var popover = Ti.UI.iPad.createPopover({ 
    width:300, 
    height:250,
    title:'Test Popover',
    arrowDirection:Ti.UI.iPad.POPOVER_ARROW_DIRECTION_UP
}); 

var win = Ti.UI.createWindow({backgroundColor: '#FFF'});
win.open();

var v = Ti.UI.createView();
win.add(v);

popover.show({
    view: v,
    animated:true
});