文章来源:http://www.cocoachina.com/bbs/read.php?tid=50798&keyword=textview
m_textView :NSTextView
m_view:包含NSTextView的视图
float ScrollLocation = 0.0;
float MaxScroll = 0.0;
[[m_textview enclosingScrollView] setLineScroll:0.0f];
[[m_textview enclosingScrollView] setPageScroll:0.0f];
ScrollLocation = [[[m_textview enclosingScrollView] contentView] bounds].origin.y;
MaxScroll = [[[m_textview enclosingScrollView] documentView] bounds].size.height - [[m_textview enclosingScrollView] documentVisibleRect].size.height;
ScrollLocation += 10;
if(ScrollLocation < 0)
{
ScrollLocation = 0;
}
else if(ScrollLocation >MaxScroll)
{
ScrollLocation = MaxScroll;
}
[[m_view contentView] scrollToPoint:NSMakePoint(0, ScrollLocation)];