【发布时间】:2015-09-05 09:26:54
【问题描述】:
我已经在段点击时重新加载了 UITableview 数据,如下图所示:
现在我想在 UISegmentedControl 点击时为 tableView 重新加载动画,与 navigationController pushViewController 相同,但在 table view 的移动之间会出现过渡屏幕
我尝试使用以下功能,但无法完全获得我想要的 -(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];
}
【问题讨论】:
-
你使用了多少个表格视图?
-
单表视图我只是重新加载数据
-
看到push view controller中使用的动画就像是从左向右移动。在你的情况下,它不是。您必须相应地设置框架,然后才能看到动画。
标签: ios objective-c uitableview uisegmentedcontrol uiviewanimation