Search code examples
cocoanstableviewnsscrollview

NSScrollView Bar not scrolling through NSTableView rows


I currently have an NSTableView inside an NSScrollView and this gets it's contents from a datasource. However, when the number of contents is larger than the view can hold, using the vertical scroll bar does not affect the contents of the table.

  • Dragging the scroll bar doesn't work
  • Clicking the Up/Down buttons doesn't work
  • Using the middle scroll wheel on a mouse does work
  • Using the arrows keys on the keyboard does work
  • The above two move the vertical scrollbar up and down

  • Tried Copy on Scroll On and Off

  • The NSTableView has two columns, one is a text field and the other is an image field

  • No errors appear in the console

This very much seems that the vertical scroll bar is connected to the table view, but only in one direction. That is the tableview changes the scrollbar but not vice versa.

Has anyone had such a problem before? Or know what could be causing it?


Solution

  • The problem here seems to have been caused by the NSTableView being in a NSCollectionView Prototype. I solved it by seperating the NSCollectionViewItem's View from the main nib into it's own so it now has it's own instance and scrolls properly.