TableView没有动画

时间:2014-12-11 11:30:47

标签: ios objective-c uitableview uiviewanimation

我想同时为UIView制作动画。但是我的UIView没有动画。一圈一圈但是我的UITableView没有动画。

[self.view addSubview:sideview];
[sidevieww setHidden:NO];

[UIView animateWithDuration:0.3 animations:^{
    [sidevieww setFrame:CGRectMake(0, 0, sidevieww.frame.size.width, sidevieww.frame.size.height)];

    [mytable setFrame:CGRectMake(240,mytable.frame.origin.y,mytable.frame.size.width,mytable.frame.size.height)];
    [mynav setFrame:CGRectMake(240,mynav.frame.origin.y,mynav.frame.size.width,mynav.frame.size.height)];
    [mybutton setFrame:CGRectMake(240, mybutton.frame.origin.y, mybutton.frame.size.width, mybutton.frame.size.height)];

} completion:^(BOOL finished) {
    sideview =true;
}];

1 个答案:

答案 0 :(得分:0)

这实际上不是配置框架的最佳方式。

用以下代码替换您的代码:

   [self.view addsubview:sideview];

   [sidevieww setHidden:NO];

    CGRect frameSideVieww = sidevieww.frame;
    frameSideVieww.origin.x = frameSideVieww.origin.y = 0;

    CGRect frameMyTable = mytable.frame;
    frameMyTable.origin.x = 240;

    CGRect frameMyNav = mynav.frame;
    frameMyNav.origin.x = 240;

    CGRect frameMyButton = mybutton.frame;
    mybutton.origin.x = 240;

[UIView animateWithDuration:0.3 animations:^{
    [sidevieww setFrame:frameSideVieww];
    [mytable setFrame:frameMyTable];
    [mynav setFrame:frameMyNav];
    [mybutton setFrame:frameMyButton];
}completion:^(BOOL finished) {
    sideview =true;
}];

另外,检查您的类是否是UIViewController的子类。