I\'m working on an iPhone application where I want to drag the table view (not the cells) upto a certain point in the screen. I have the tableview sitting in the bottom half
Can you try this code for moving tableview
[UIView animateWithDuration:1.5 animations:^
{
//ADD CODES HERE FOR STARTING STATE (FRAME FOR UITABLEVIEW )
// eg: table.frame=CGRectMake(0,320,320,200); tableview lying on bottom of viewcontroller with 200px height
} completion:^(BOOL finished)
{
// ADD CODES HERE TO MAKE YOUR FINAL FRAME OF UITABLEVIEW
// eg: table.frame=CGRectMake(0,0,320,200); tableview moving to top of viewcontroller with 200px height
}];
try this let me know the results
PLEASE BEFORE MARKING DOWN VOTE LET ME KNOW THE REASON ,BECAUSE THIS CODES IS WORKING FOR ME
If I rightly understand the question, the simplest solution is to programmatically set the tableView header to the desired image. (I think this is like what Path does for setting a location, with the exception that they are using a map not an image.)
UIImage *image = [UIImage imageNamed:@"image_name"];
UIImageView *imageView = [[UIImageView alloc] initWithImage:image];
[self.tableView setTableHeaderView:imageView];
This is equivalent to dragging a UIImageView, with the appropriate image, onto the tableView header in a storyboard.
Please note: The table header view is different from a section header. See Documentation for more info.
I think the way you're doing it is fine. You just need to stop the UIGestureRecognizer from handling any more touches after a certain point. So what I would do (with the least amount of change to your existing code) is just override the delegate function:
- (BOOL)gestureRecognizer:(UIGestureRecognizer *)gestureRecognizer shouldReceiveTouch:(UITouch *)touch
In that function, analyze the position of the table view and if the table view has reached a certain height already, return NO. This will stop the UIPanGestureRecognizer from accepting the touch event and pass it up the chain, which should go straight to the UIScrollView of the table view.
Alternative, if I had the time to figure this out, I would try to accomplish this with the image as the table's header (self.tableView.tableHeaderView). This way all of the scrolling is done within the the scrollview of the table and the table's frame doesn't have to move. If you wanted to add some cool effects to the tableHeaderView, you could always override the UIScrollViewDelegate function - (void)scrollViewDidScroll:(UIScrollView *)scrollView
and slightly shift the image in the header as the table scrolls up the initial half screen (this is the same effect that Path does). However, this wouldn't allow you to peg the image at the very top of the table view... the entire image would scroll away. Just my 2 cents. :)