NSScrollView滚动条怎么让它停在指定的位置或者点
1个回答
2015-01-11
展开全部
以下代码应该可以的。
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_textview scrollPoint:NSMakePoint(0, ScrollLocation)];
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_textview scrollPoint:NSMakePoint(0, ScrollLocation)];
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询