samedi 27 juin 2015

how to make a uitableview know about where to scroll for uncreated views yet

I have a UITableView which has up to 600 items in it. They are split between headers and items (like 30 headers of 15-20 items each). It is a catalog and has to mimick the printed catalog.

There is also a navigation pop-up view that shows only the headers that a user can overlay to the main table view. It is represented like this:

header
 \subheader
header2
\subheader
  \subheader

And our code for navigating is like this:

  func tapOnMenuHeaderView(recognizer: UITapGestureRecognizer)
  {
    self.hideModalNavigation()
    self.mainTV.reloadData()
    self.mainTV.scrollToRowAtIndexPath(NSIndexPath(forRow: self.menuHeaderPositions[recognizer.view!.tag]!, inSection: 0), atScrollPosition: UITableViewScrollPosition.Top, animated: true)
  }

However, it doesn't go to the right place many times. It seems to always be short and gets less accurate the further down you go. Is this a limitation to scrollRowAtIndexPath and is there a way I could force a full reload or something? The only way I could get this to work was to remove using a tableview and do everything as UIViews and just increment it in a scroll view. How would I make it so that our overlay navigation scrolls to the correct place?

Aucun commentaire:

Enregistrer un commentaire