2014-03-06 31 views
0

我開發了一個示例代碼,其中我創建了一個窗口小部件,其中只添加了一個視圖,並在其中添加圖像視圖。當我直接從控制器的tss應用樣式時它工作得很好,但是當使用「formFactor」時它不起作用。澄清相同的請檢查代碼放在這裏。Titanium Appcelerator合金不支持窗口部件的formFactor樣式

您可以創建一個新的合金項目和測試相同與下面的代碼:

注:所有的依賴關係都包含在config.json

widget實現:

widget.xml 

<Alloy> 
    <View id="section" class="section"></View> 
</Alloy> 


widget.tss 

".section":{ 
    backgroundColor: 'red', 
    layout : 'vertical' 
}, 


widget.js 

var args = arguments[0] || {}; 
$.section.applyProperties(args); 

$.setData = function(view) { 
    $.section.add(view); 
} 

Codin g下索引頁

Index.xml 

<Alloy> 
<ScrollView class="baseView"> 
    <Widget id="contentView" class="contentView" src="com.investis.scrollablesection"></Widget> 
</ScrollView> 
</Alloy> 


Index.tss 

".contentView [formFactor=handheld]":{ 
    backgroundColor: 'green', 
    width: Ti.UI.FILL, 
    height: Ti.UI.SIZE 
} 

Index.js 

var imgView = Ti.UI.createView({ 
    backgroundColor: 'yellow', 
    top: 20, 
    left: 0, 
    right: 0, 
    width: Ti.UI.FILL, 
    height: Ti.UI.SIZE 
}); 
$.contentView.setData(imgView); 

同樣的事情工作,如果我從.contentViewIndex.tss

+0

SDK:3.2.1,iOS:7,在模擬器中,不工作formFactor –

回答

0

刪除[formFactor=handheld]從你的回答中缺少一些關鍵細節,像什麼平臺你在建設中,鈦的是什麼版本您正在使用的SDK,並且您不清楚您期望的與您看到的問題相比。

使用您的代碼構建iOS模擬器,我得到一個填充屏幕寬度的綠色滾動視圖,大約20dp高 - 在index.tss類上有或沒有[formFactor = handheld]限定符。如果我增加scrollview的高度,我會看到一個黃色的視圖。所以有什麼問題?

相關問題