[英]How to animate tableView reload on UISegmentedControl click as pushviewcontroller
我已經在段點擊上重新顯示了UITableview數據,如下圖所示:
現在我想在UISegmentedControl上動畫tableView重載點擊與navigationController pushViewController
相同,但是在表格視圖的移動之間出現過渡畫面
我試着使用以下但是無法完全得到我想要的東西 - (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];
}
我建議你在頂部使用UICollectionView
並使用視圖的寬度創建自定義單元格包含UITableView
以及當段控制值更改時:滾動到要使用的特定單元格。 還記得制作
CollectionView PagingEnabled = YES
請使用以下代碼。
-(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);
}];
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.