2013-08-03 28 views
0

我正在创建一个iOS应用程序,用户在其中单击图像并将字母“A”连接到字符串变量。TextArea滚动不起作用[Titanium]

现在,我有一个文本区域的变量字符串的值。每次将新字母连接到变量字符串时,都会更新文本区域值。

问题是,当文本区域的宽度;之后添加的字母无法看到。如何让输入的最后一个字符在字符串长度超过文本区域的宽度后始终可见?

需要解决这个问题!

代码:

var image = Ti.UI.createImageView({ 
backgroundColor:'red', 
width: 200, 
height:100 
}); 

win.add(image); 

var scroll = Ti.UI.createScrollView({ 
top:40, 
left:230, 
width:290, 
height:50, 
borderRadius:10, 
backgroundColor:'transparent', 
scrollType:'horizontal', 
scrollingEnabled : 'true', 
showVerticalScrollIndicator:true, 
showHorizontalScrollIndicator:true, 
}); 

win.add(scroll); 



var textType = Ti.UI.createTextArea({ 
backgroundColor:'#E6E6E6', 
borderColor:'blue', 
borderRadius:10, 
top:0, 
left:-70, 
width:390, 
height:50, 
font:{fontSize:26, fontFamily:customFont}, 
editable:true, 
enabled:false, 
textAlign:'right', 
scrollable:true, 
horizontalScroll : true, 
scrollType:'horizontal' 
}); 

scroll.add(textType); 

image.addEventListener('click, function(e){ 
    string = string + "A"; 
    textType.setValue(string); 
} 

回答

0

你可以尝试设置horizontalWrap:true;,这使文本显示的下一行,而不是关闭屏幕。

或者,如果textType.width > scroll.width设置为scroll.contentOffset.x = textType.width - scroll.width。我不确定Titanium的语法细微差别,但这是您在常规Objective-C/iOS程序中的做法。