我在UIScrollView中成功显示UILabel, 但如何跳过/跳转/动态结束文本? 我的代码如下并且工作完美。 我必须添加哪些代码才能跳转到文本末尾? 可能吗 ? 我尝试重现日志/跟踪的效果...... 谢谢 佛瑞德
-(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];
}
答案 0 :(得分:1)
答案 1 :(得分:1)
您可以使用setContentOffset
的{{1}}方法进行滚动,例如:
UIScrollView