我有一個UITextView,我要表現出水平的文字,我的UITextView有一個靜態的寬度的UITextView只是水平滾動的幫助
[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 161, 23)];
所以當的UITextView文本的長度大於23,我需要的UITextView水平滾動,請幫我...
我有一個UITextView,我要表現出水平的文字,我的UITextView有一個靜態的寬度的UITextView只是水平滾動的幫助
[[UITextView alloc] initWithFrame:CGRectMake(0, 0, 161, 23)];
所以當的UITextView文本的長度大於23,我需要的UITextView水平滾動,請幫我...
mscrollview.contentSize = CGSizeMake(180,30);
mscrollview.showsHorizontalScrollIndicator = YES;
使用此2行。
把這段代碼 初始化
[txt setContentOffset:CGPointMake(give_high_value_here_than_content, y)];
好運
如果使用界面生成器然後就檢查屬性後。
show horizontal scrolling.
默認情況下這個屬性是不啓用
不做任何事情 – SleepsOnNewspapers 2015-04-11 17:57:55
這隻適用於滾動視圖。不會更改文本的lineBreakMode – SleepsOnNewspapers 2015-04-11 18:25:15
- (void)viewDidLoad {
// We restrict the horizontal scrolling here.
self.textView.contentSize = self.textView.frame.size;
}
實現此文本視圖委託方法。
現在當輸入的字符大於23時,我們將文本視圖的內容大小設置爲更高的值,以便自動啓用水平滾動。
- (void) textViewDidChange:(UITextView *) tView {
if (tView.text.length > 23) {
// Set some higher width of the text view content size.
tView.contentSize = CGSizeMake(200.0f, tView.frame.size.height);
}
}
我只是想在水平滾動的UITextView,但聽起來沒有工作 – juliet 2011-06-08 05:49:04
你必須處理的集尋呼廈門國際銀行文件來實現,以及[TXT contentSize:cgrectmake()];和[txt setContentStretch:(CGRect)]; – NIKHIL 2011-06-08 09:27:50