How to animate reload of tableView on UISegmentedControl by clicking pushviewcontroller button
I have UITableview data on a segment click as shown in the image below:
Now I want to animate the reload of the tableView on the UISegmentedControl by clicking the same navigationController pushViewController
but the transition screen appears between moving the table view
I'm trying to use the following but couldn't completely get what I want - (void) SwipeGestureRecognize {
UISwipeGestureRecognizer * swipeleft=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swipeleft:)];
swipeleft.direction=UISwipeGestureRecognizerDirectionLeft;
[self.view addGestureRecognizer:swipeleft];
UISwipeGestureRecognizer * swiperight=[[UISwipeGestureRecognizer alloc]initWithTarget:self action:@selector(swiperight:)];
swiperight.direction=UISwipeGestureRecognizerDirectionRight;
[self.view addGestureRecognizer:swiperight];
}
-(void)swipeleft:(UISwipeGestureRecognizer*)gestureRecognizer
{
//past Order
[UITableView animateWithDuration:0.5f animations:^{
self.tableView.frame = CGRectOffset(self.tableView.frame, [Util window_width],0);
}];
self.tableView.frame = CGRectMake(0, 0, 0-[Util window_width], [Util window_height]);
[UITableView animateWithDuration:0.5f animations:^{
self.tableView.frame = CGRectOffset(self.tableView.frame, [Util window_width],0);
}];
segmetControl.selectedSegmentIndex = 1;
[self action:Nil];
}
-(void)swiperight:(UISwipeGestureRecognizer*)gestureRecognizer
{
//Current Order
[UITableView animateWithDuration:0.5f animations:^{
self.tableView.frame = CGRectOffset(self.tableView.frame, [Util window_width],0);
}];
self.tableView.frame = CGRectMake(0, 0, 0-[Util window_width], [Util window_height]);
[UITableView animateWithDuration:0.5f animations:^{
self.tableView.frame = CGRectOffset(self.tableView.frame, [Util window_width],0);
}];
segmetControl.selectedSegmentIndex = 0;
[self action:Nil];
}
+3
source to share
2 answers
Please use the code below.
-(void)swipeleft
{
self.tableView.frame = CGRectMake(self.tableView.frame.size.width, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height)
[UITableView animateWithDuration:0.5f animations:^{
self.tableView.frame = CGRectMake(0, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
}];
}
-(void)swiperight{
self.tableView.frame = CGRectMake(-self.tableView.frame.size.width, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
[UITableView animateWithDuration:0.5f animations:^{
self.tableView.frame = CGRectMake(0, self.tableView.frame.origin.y, self.tableView.frame.size.width, self.tableView.frame.size.height);
}];
}
+1
source to share