Hi,
I have the following setup:
A UITableView which list summary information about items.
When you select an item, you switch to another UITableView, which contains Detail Information about the selected item. The detail information is presented as a List too (UITableView).
Now, say I select item No. 3 in the summary list, i'll switch to the detail view and show detail information about that No. 3 item.
What I'd like now in this Detail UITableView is to be able to:
a) use normal vertical scrolling (just normal behaviour of a UITableView)
b) Here's the tricky part: detect horizontal scrolling (swipes) within the UITableView to switch to the previous/next item Detail, eg. right-swipe = show Item No. 2 Detail, left swipe = show No. 4 Detail.
I have written a custom UITableView and implemented
Now, this implementation seemed to work at first, but the problem is that when i do a vertical scroll to the bottom of the table, everything is fine, but as soon as i retouch the display, say to scroll up a bit, it jumps back to the top of the table.
Any idea ?
I have the following setup:
A UITableView which list summary information about items.
When you select an item, you switch to another UITableView, which contains Detail Information about the selected item. The detail information is presented as a List too (UITableView).
Now, say I select item No. 3 in the summary list, i'll switch to the detail view and show detail information about that No. 3 item.
What I'd like now in this Detail UITableView is to be able to:
a) use normal vertical scrolling (just normal behaviour of a UITableView)
b) Here's the tricky part: detect horizontal scrolling (swipes) within the UITableView to switch to the previous/next item Detail, eg. right-swipe = show Item No. 2 Detail, left swipe = show No. 4 Detail.
I have written a custom UITableView and implemented
Code:
#define HORIZ_SWIPE_DRAG_MIN 12
#define VERT_SWIPE_DRAG_MAX 4
- (void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
startTouchPosition = [touch locationInView:self];
}
- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = touches.anyObject;
CGPoint currentTouchPosition = [touch locationInView:self];
// If the swipe tracks correctly.
if (fabsf(startTouchPosition.x - currentTouchPosition.x) >= HORIZ_SWIPE_DRAG_MIN &&
fabsf(startTouchPosition.y - currentTouchPosition.y) <= VERT_SWIPE_DRAG_MAX)
{
// It appears to be a swipe.
if (startTouchPosition.x < currentTouchPosition.x)
[self myProcessRightSwipe:touches withEvent:event];
else
[self myProcessLeftSwipe:touches withEvent:event];
}
else
{
// default handling
[super touchesMoved:touches withEvent:event];
}
}
Now, this implementation seemed to work at first, but the problem is that when i do a vertical scroll to the bottom of the table, everything is fine, but as soon as i retouch the display, say to scroll up a bit, it jumps back to the top of the table.
Any idea ?