gpt4 book ai didi

javascript - 扩展 Titanium 对象在 iOS 上不起作用

转载 作者:行者123 更新时间:2023-11-30 04:38:50 25 4
gpt4 key购买 nike

我想知道是否有人可以解释为什么钛 View 代理的扩展在 iOS 上不起作用,但在 Android 平台上运行得很好。

Ti 移动 SDK:1.7.0RC1 和 1.6.2iOS 开发工具包:4.2Android API:(谷歌 API)2.2

这是一个非常简单的用例:

var useCaseView = Ti.UI.createView({
layout: 'vertical',
right:0,
left:0,
top:0,
height:200,
backgroundColor:'#fff'
});



var outputSwitch = Ti.UI.createSwitch({
value: true
});



outputSwitch.setTopValue = function(newValue) {
Ti.API.info('setTop' + newValue);
outputSwitch.top = newValue;
};



outputSwitch.setTopValue(50);



useCaseView.add(outputSwitch);

我想要完成的是向开关的 View 代理添加一个方法(在本例中为 setTopValue)并在事后调用它。

这在 Android 上运行良好,但在 iOS 上,Ti.API.info 调用甚至没有被命中,表明它只是忽略了该方法。

虽然这个例子很简短,但我真正想做的是“子类化”开箱即用的 Titanium UI 组件,并添加一些通用方法供它们共享,以减少重复代码.

有谁知道 iOS SDK 是否会以某种方式禁止子类化它的“普通”UI 组件?

最佳答案

我们在其他地方收到了答案(或者更确切地说是解决方法):

i have found that naming functions with a prefix of 'get' or 'set' cause problems. Try renaming the function -- Aaron Saunders

果然,重命名函数会导致此代码按预期工作。

http://developer.appcelerator.com/question/121114/extending-objects-not-working-on-iphone

关于javascript - 扩展 Titanium 对象在 iOS 上不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6362576/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com