我成功地在UIScrollView中顯示UILabel, 但是如何跳過/跳轉/到文本結尾動態?我的代碼如下,工作完美。 我必須添加哪些代碼才能跳轉到文本的末尾? 有可能嗎? 我嘗試重現日誌/跟蹤的效果... 感謝 弗雷德如何在UIScrollView中使用dynamicaly?
-(void) log:(NSString *)msg
{
// alocate and initialize scroll
UIScrollView *myScroll = [[UIScrollView alloc] initWithFrame:CGRectMake(0.0f, 20.0f, 320.0f, 460.0f)];
// alocate and initialize label
UILabel *myLabel = [[UILabel alloc] initWithFrame:CGRectMake(0.0f, 20.0f, 320.0f, 460.0f)];
myLabel.text = msg; //a long text
// set line break mode to word wrap
myLabel.lineBreakMode = UILineBreakModeWordWrap;
// set number of lines to zero
myLabel.numberOfLines = 0;
// resize label
[myLabel sizeToFit];
// set scroll view size
myScroll.contentSize = CGSizeMake(myScroll.contentSize.width, myLabel.frame.size.height);
// add myLabel
[myScroll addSubview:myLabel];
// add scroll view to main view
[self.view addSubview:myScroll];
// release label and scroll view
[myLabel release];
[myScroll release];
}
親愛剛剛成立ContentOffset是滾動型的 –
@ user1164417請註明任何所接受,如果它幫你的答案。 – Mrunal