1

テーブルビューがあり、行の1つにボタンが含まれています。ユーザーがボタンを押すと、テキスト領域を含む行をテーブルに追加します。新しい行がテーブルビューの一番上にあり、キーボードが開いていることを望みます。これが私が試したことです:

function addNewComment() {
    var newComment = new NewComment(tableView.data[0].rows.length);

    //I add the spacer so that if the added row is the last in the table, it can still be at the top of the view
    var spacer = Ti.UI.createTableViewRow({
        height:250,
        backgroundColor: 'white'
    });

    //There are 6 rows of information in the table before the comments start
    tableView.appendRow(spacer, {animated:false});
    tableView.insertRowAfter(5, newComment, {animationStyle:Titanium.UI.iPhone.RowAnimationStyle.DOWN});

    //The listener for this just focuses the text area
    Ti.App.fireEvent('newCommentAddedToView');
    tableView.scrollToIndex(6,{animated:true,position:Ti.UI.iPhone.TableViewScrollPosition.TOP});
}

これが実行されると、メソッドの最後の行が呼び出されていないかのようになります。新しい行がスクロールして表示されますが、一番上までは表示されません。テキスト領域に入力しているものを確認するのに十分なだけスクロールして表示されます。次に、行を手動でスクロールして上部に揃えることができますが、これを自動的に行いたいと思います。これを達成する方法はありますか?

前もって感謝します。

4

1 に答える 1