저는 tableview가 있고 행 중 하나에는 버튼이 있습니다. 사용자가 버튼을 누르면 텍스트 영역이 포함 된 테이블에 행을 추가합니다. 새로운 행을 tableview 맨 위에 놓고 키보드를 열었 으면합니다. 내가 시도한 것은 다음과 같습니다.TextArea에 포커스가있는 경우 TableView ScrollToIndex
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});
}
이 메서드를 실행하면 메서드의 마지막 줄이 호출되지 않은 것처럼 보입니다. 새 행은보기로 스크롤되지만 맨 위로는 이동하지 않습니다. 텍스트 영역에서 입력 내용을 볼 수있을 정도로만 화면을 스크롤합니다. 그런 다음 상단과 정렬되도록 행을 수동으로 스크롤 할 수 있지만이 작업은 자동으로 수행하고 싶습니다. 이것을 달성 할 방법이 있습니까?
미리 감사드립니다.
해당 색인이 맞습니까? – Anand