あなたはこれに間違った方法でアプローチしていると思います。私の理解では、直接対話することはベストプラクティスではありませんNSScroller
(また、これが機能するとは思いません)。
この質問への回答を参照してください。これは、あなたのシナリオに似ていると思います。最善の方法は、スクロール ビューの原点を設定することですContentView
。
その質問の答えをC#に変換しました:
public override void AwakeFromNib()
{
tableView.EnclosingScrollView.ContentView.PostsBoundsChangedNotifications = true;
NSNotificationCenter.DefaultCenter.AddObserver(this, new Selector("boundsDidChangeNotification"),
NSView.BoundsChangedNotification, tableView.EnclosingScrollView.ContentView);
base.AwakeFromNib();
}
[Export("boundsDidChangeNotification")]
public void BoundsDidChangeNotification(NSObject o)
{
var notification = o as NSNotification;
var view = notification.Object as NSView;
var position = view.Bounds.Location;
Console.WriteLine("Scroll position: " + position.ToString());
}
次のような特定のポイントまでスクロールできます。
PointF scrollTo = new PointF(19, 1571);
tableView.EnclosingScrollView.ContentView.ScrollToPoint(scrollTo);
tableView.EnclosingScrollView.ReflectScrolledClipView(tableView.EnclosingScrollView.ContentView);
これは興味深いかもしれません: Mac 用スクロール ビュー プログラミング ガイド