0

しばらくこれに取り組みました。セミバグのようです。

次のように、leftButtonまたはrightButtonをtextFieldに追加する場合:

var leftButton = Ti.UI.createButton({
    image: 'someImage.png'
})
var textField = Ti.UI.createTextField({

    leftButton: leftButton,
    leftButtonMode: Ti.UI.INPUT_BUTTONMODE_ALWAYS,
    leftButtonPadding: 100

})

...そうすると、ボタンが表示されなくなります。なんで?

4

3 に答える 3

1
var win = Titanium.UI.createWindow({
    title:"Configuring text field and text area keyboard types",
    backgroundColor:"#347AA9",
    exitOnClose:true
});

//These buttons will appear within the text field
var clearButton = Titanium.UI.createButton({
    title:"Clear",
    height:24,
    width:52
});

var submitButton = Titanium.UI.createButton({
    title:"Submit",
    height:24,
    width:60
});

var textField = Titanium.UI.createTextField({
    top:"25%",
    height:35,
    width:600,
    backgroundColor:"#ffffff",
    borderStyle:Titanium.UI.INPUT_BORDERSTYLE_ROUNDED,
    hintText:"Type something",
    keyboardType:Titanium.UI.KEYBOARD_DEFAULT,
    leftButton:clearButton,
    rightButton:submitButton
});

clearButton.addEventListener("click", function(e){
    //Clear the value of the text field
    textField.value = "";
});

submitButton.addEventListener("click", function(e){
    //Pretend to submit the value of the text field
    //Be sure that you've typed something in!
    if(textField.value != ""){
        alert(textField.value); 
    }else{
        alert("Enter some text");
    }
});

//Add an event listener to the window that allows for the keyboard or input keys to be hidden if the user taps outside a text field
//Note: each text field to be blurred would be added below
win.addEventListener("click", function(e){
    textField.blur(); // Cause the text field to lose focus, thereby hiding the keyboard (if visible)
});

win.add(textField);

win.open();
于 2015-09-17T11:25:26.370 に答える
1

このコードには 2 つの問題がある可能性があります。1-ボタンに割り当てた画像パスを確認してください..?(高さ、幅)テスト目的で、システムボタンを使用して、表示されるかどうかを確認してください.?

var leftButton = Titanium.UI.createButton({
    style:Titanium.UI.iPhone.SystemButton.DISCLOSURE
});

2 秒の問題は、左ボタンのパディングにある可能性があります。パディングなしで使用してみて、何が起こるかを確認してください。

于 2012-11-30T06:51:02.070 に答える
0

問題はleftButtonModeプロパティにあります。値を指定すると、ボタンは表示されません。このプロパティを使用しない場合、ボタンは問題なく表示されます。

パディングプロパティは、leftButtonの問題ではありません。ただし、rightButtonで使用すると、ボタンが画面の外に表示される可能性があります。私も負の値を試しましたが、成功しませんでした。

leftButtonオプションとrightButtonオプションはAndroidでは機能しないことにも注意してください。

于 2012-11-23T16:07:30.753 に答える