2014-11-04 139 views
-1

我试图显示和隐藏的tableView与动画显示和隐藏的UITableView动画

“从左至右&从右到左的过渡”这是我已经厌倦了它的工作,但使用一个随机值后在CGRectMake,

不要任何人都可以帮我解决这个问题,请

-(void)Display:(UITableView *)tableView :(UIView *)view{ 
     tableView.alpha=1; 
     [UIView animateWithDuration:0.35 
         animations:^{ 
           tableView.frame = CGRectMake(-209, 440, 180, 209); 

         } 
         completion:^(BOOL finished){ 

          [tableView setHidden:YES]; 

         } 
     ]; 
    } 

-(void)Hide:(UITableView *)tableView :(UIView *)view :(int)tb{ 
    tableView.alpha=1; 
    [tableView setHidden:NO]; 

    [UIView animateWithDuration:.45 
        animations:^{ 
          tableView.frame = CGRectMake(3, 442, 180, 209); 

        } 
    ]; 
} 
+1

请告诉我们你已经尝试了什么。 – Dave 2014-11-04 11:10:32

+0

@Dave这里我已经累了 – fourthnovember 2014-11-04 11:29:54

+0

@fourthnovember你说它在上面的帖子中有效。你的问题是什么? – 2014-11-05 18:31:08

回答

1

您可以使用此代码:

[UIView transitionFromView:firstView 
        toView:secondView//table view 
        duration:0.5 
        options:UIViewAnimationOptionTransitionFlipFromLeft 
       completion:^(BOOL finished) { 

        [firstView.superView addSubview:secondView]; 

        [firstView.superView sendSubviewToBack:firstView]; 
       }]; 
+0

mityaika07谢谢你,我试过你的解决方案,它的工作,但所有的观点不只是我的桌面翻转不是幻灯片转换左右,我我曾尝试这2方法它的工作,但我迷路的CGRectMake,有也许更好的方法来设置从左到右使用这个过渡?没有以随机的方式设置CGRectMake – fourthnovember 2014-11-04 11:24:02

0

如果你想要像Facebook这样的动画,然后使用: - ECSlidingViewController

http://kingscocoa.com/tutorials/slide-out-navigation/

或者

如果你想正常的动画然后设置框架和减少阿尔法从1.0到0.0与持续时间。

+0

谢谢,但它不是我想要做的,只是试图显示和隐藏一个可用的视图与动画 – fourthnovember 2014-11-04 11:26:32

+0

好吧,然后使用这可能是这是有用的: - 最初设置tableview的框架(0 ,(0,0,460)然后在动画部分(0,0,320,460) - (void)animateView:(UIView *)theView toPosition:(CGPoint)thePosition \t [UIView beginAnimations:nil context:NULL]; \t [UIView setAnimationDuration:2]; \t //将中心设置为最后的位置 \t //将变换设置回身份,从而撤销以前的缩放效果。 theView.frame = CGRectMake(0,0,320,460); \t theView.transform = CGAffineTransformIdentity; \t [UIView commitAnimations]; } – abhinav 2014-11-04 11:30:20

1

很难说出你的问题,但是通过“从左到右&从右到左过渡” 你想要这样的东西吗?

对于动画出左

[UIView animateWithDuration:1.0f 
          delay:0.0f 
         options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut 
        animations:^{ 


         self.tableView.frame = CGRectMake(0.0f, -self.tableView.frame.size.width, self.tableView.frame.size.width, self.tableView.frame.size.height); 

        } 
        completion:NULL]; 

对于动画出右

[UIView animateWithDuration:1.0f 
          delay:0.0f 
         options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut 
        animations:^{ 


         self.tableView.frame = CGRectMake(0.0f, self.view.bounds.size.width, self.tableView.frame.size.width, self.tableView.frame.size.height); 

        } 
        completion:NULL]; 

对于

[UIView animateWithDuration:1.0f 
          delay:0.0f 
         options:UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveEaseInOut 
        animations:^{ 


         self.tableView.frame = CGRectMake(0.0f, 0.0f, self.tableView.frame.size.width, self.tableView.frame.size.height); 

        } 
        completion:NULL]; 
动画

你可以把表重新加载等你完成块?然后动画tableView回来?

+0

可以üplz解释我在CGRectMake中的第一个点值,他们工作很好的样本,但我只是设置结束点不是在左上角的视图结束。做效果幻灯片并隐藏 – fourthnovember 2014-11-04 11:56:50

+0

当然,所以CGRectMake是有序的origin.X,origin.Y,宽度,高度...所以移动视图(在这种情况下,一个tableview)的权利..我们增加了原点。如果我们想将它向左移动,我们就会减少。 – Magoo 2014-11-04 22:41:46