Touches moves not detected
CKzu opened this issue · 7 comments
Hi and thank you for the great job on that library,
I'm having an issue with what should be a default behavior of the index:
When I tap an item, tableViewIndex(tableViewIndex, didSelectItem, atIndex)
is called, but not if I swipe through the index bar. It seems like touchesBegan
is called, but not touchesMoved
.
Most of my code is copied from the demo example which works perfectly fine, so I don't really know where to investigate.
Do you by any chance have an idea of what causes the issue?
Let me know if you need more info
Thanks!
Hi,
thanks for the kind words!
Which setup do you use? Manual layout or using TableViewIndexController?
Here's how I'm configuring the index :
tableViewIndexController = TableViewIndexController(tableView: homeTableView)
tableViewIndexController.tableViewIndex.delegate = self
tableViewIndexController.tableViewIndex.dataSource = self
tableViewIndexController.tableViewIndex.backgroundView?.backgroundColor = UIColor.clearColor()
tableViewIndexController.tableViewIndex.font = UIFont(name: "HelveticaNeue-Medium", size: 11)
tableViewIndexController.tableViewIndex.tintColor = UIColor.darkGrayColor()
tableViewIndexController.tableViewIndex.indexInset = UIEdgeInsets(top: 3, left: 5, bottom: 3, right: 5)
tableViewIndexController.layouter = { homeTableView, tableIndex in
var frame = tableIndex.frame
frame = self.indexView.frame
tableIndex.frame = frame
}
where self.indexView
is a view I set up in IB to have a frame set with Autolayout.
homeTableView
is my table view, which is contained in a UIViewController
.
didSelectItem
method is basically the same as the one you have in your example code:
func tableViewIndex(tableViewIndex: TableViewIndex, didSelectItem item: UIView, atIndex index: Int) {
let sectionIndex = self.mapIndexItemToSection(item, index: index)
if sectionIndex != NSNotFound {
let sections = homeTableView.numberOfSections
let indexPath = NSIndexPath(forRow: NSNotFound, inSection: sectionIndex >= sections ? sections - 1 : sectionIndex)
homeTableView.scrollToRowAtIndexPath(indexPath, atScrollPosition: .Top, animated: false)
} else {
homeTableView.scrollToRowAtIndexPath(NSIndexPath(forRow: 0, inSection: 0), atScrollPosition: .Top, animated: false)
}
}
Could you please write here the value of a frame you set to the table index?
Here's the frame for MYTableViewIndex
at runtime:
MYTableViewIndex: frame = (351 284; 24 383);
And here's the frame for MYTableViewIndex.IndexView
:
MYTableViewIndex.IndexView: frame = (5 3.5; 14 378);
I noticed MYTableViewIndex.IndexView
is a bit smaller, could it be the cause of the problem?
Hm, probably it is too narrow so the finger can't hit the touch area.
By default Table index is 44pt width. Most of its area is transparent and only needed for touch handling. If you want to modify the visible part of it, you can use indexInset property of TableViewIndex.
Upon further inspection, it seems to work sometimes, it can swipe on a few indexes (like 2-4). I guess you're right about the fact that touch area is too narrow. I'm going to investigate further and let you know if I find a solution.
Well, the solution is simple - make it at least 44pt wide.
Is there any particular reason why you want it to be narrower than that?