I have a UIImageView that I am able to successfully move above the UITableView. Both views (i.e. UIImageView, and UITableView) are the sub-views of the original view of the view controller. UIImageView I'm moving forward using a UIPanGestureRecognizer object which then calls the method GestureDetected. My method for panGestureDetected looks like this:
- (zero) panGestureDetected: (UIPanGestureRecognizer *) identifier {_startLocation = [identifier locationInView: _imageView]; NSLog (@ "dot:% d", _start location); En selected RO = [_table index selected road for text] .OO; NSLog (@ "current line is:% d", selected row); CGPoint newCenter = _imageView.center; NewCenter.y = [Identifier Location Inview: [_ Image View Supervision]]. Y; _imageView.center = newCenter; } The user can drag UIImageView up and down over UITableView. However, what I would like to do is UIImageView "Link" or "Connect" with whatever UITableViewCell / Row is covered that UIImageView is covered, or if near UIImageView is between two rows, take UIImageView to that line Here is an image of what I am talking about here:
In this image, the UIImageView is close to row 2 to 1, then the user after its / Which removes finger, UIImageView simply will move a little more and row cover 1, line sense 1 seems to make "active line" so to speak to me that it. At the moment, the movement of my UIImageView, and my UITableView are completely different from each other, but when it comes to this movement where the user is pulling UIImageView, I want there to be a connection. Can anyone show me this?
Use the UITableView method indexPathRowAtPoint: To determine the line at which the user had stopped moving the image, then cellForRowAtIndexPath to get the cell, then the center of the cell, then UIImageView center on the cell center set on. Something like this: NSIndexPath * indexPath = [myTableView indexPatrootoutpoint: touchpoints]; UITableViewCell * cell = [myTableView cellForRowAtIndexPath: indexPath]; MyUIImageView.center = cell.contentView.center; You can also make the last statement alive, so instead of jumping it runs on the cell easily. Something like this:
[UIView Animation: 0.25 Animation: ^ {myUIImageView.center = cell.contentView.center; }]; Inside the gesture identifier handler:
- (zero) myGestureRecognizerHandler: (UIPanGestureRecognizer *) gestureRecognizer {CGPoint contact formula = [gestureRecognizer locationInView: myTableView]; NSIndexPath * indexPath; UITableViewCell * cell; Switch ([gestureRecognizer state]) {Case UIGestureRecognizerStateBegan: // UIGestureRecognizerStateBegan is the stuff for ... Case UIGestureRecognizerStateChanged: // UIGestureRecognizerStateChanged, for example, do stuff for myUIImageView.center = Touchpoint; Case UIGestureRecognizerStateEnded: Index = [myTableView IndexPropertyPortePoint: TouchPoint]; Cell = [myTableView cellForRowAtIndexPath: indexpath]; {[UIView animatedDudication: 0.25F Animation: ^ {myUIImageView.center = cell.contentView.center; }]; } break; Case UIGestureRecognizerStateCancelled: Case UIGestureRecognizerStateFailed: Default: // Canceled / Failed / ... Accessories for Brake; }}
No comments:
Post a Comment