簡體   English   中英

如何在鈦(合金)中使用后布局

[英]how to use postlayout in titanium (Alloy )imageview

在Titanium 3.x(Alloy)中使用后布局的示例代碼:

視圖:

 <Alloy>
    <Window class="container">
        <Label id="testLabel" onClick="doClick">Hello, World</Label>
        <ImageView id="testImgView" autoStyle="true" ></ImageView>
    </Window>
</Alloy>

控制器:

 $.testLabel.addEventListener('postlayout', function(e) {
        Ti.API.info('Label postlayout working!');
    });
     $.testImgView.image='default.png';
     $.testImgView.addEventListener('postlayout', function(e) {
        Ti.API.info('Img postlayout working!');
    });
     $.index.open();

結果:

[INFO][TiAPI   ( 2188)]  Label postlayout working!

沒錯,我剛剛在Android上嘗試了您的代碼,但它不適用於3.1.3GA版本。 它一定是一個錯誤。

如果您覺得這不方便,可以使用

<View id="testImgView" autoStyle="true" ></View>

$.testImgView.backgroundImage='/default.png';

它會起作用

或者您可以在此處創建問題

編輯

我已經在iPhone Simulator SDK 6.1上嘗試過,它可以很好地觸發imageView postlayout事件

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM