0
我試圖滾動的NSScrollView使用此代碼視圖的底部:滾動NSScrollView不工作
NSPoint newScrollOrigin;
if ([[self.chatScreen documentView] isFlipped]) {
newScrollOrigin=NSMakePoint(0.0,NSMaxY([[self.chatScreen documentView] frame])-NSHeight([[self.chatScreen contentView] bounds]));
} else {
newScrollOrigin=NSMakePoint(0.0,0.0);
}
self.chatScreen.backgroundColor=[NSColor redColor];
[[self.chatScreen documentView] scrollPoint:newScrollOrigin];
這些來自這裏:Apple doucmentation on scrolling
當我運行我的程序,它部分滾動到視圖的底部,屏幕顯示視圖的頂部(默認開始位置),但當我嘗試滾動時,它跳轉到頁面的底部,然後我可以正常滾動。
如果我滾動到視圖的任何部分,下一次它接收到更新(觸發它跳回到底部),看起來沒有任何事情發生,直到您嘗試滾動,這再次導致它跳回到頁面的底部。
在此先感謝。
聽起來像一些滾動代碼是在不需要的時間觸發的。如果我理解正確,當您嘗試手動滾動時它會自動滾動? – Volker
你從哪裏調用此代碼? – Flexicoder
@Flexicoder我從一個單獨的線程調用代碼 – Alex