OGeek|极客世界-中国程序员成长平台

标题: iphone - 使用 block 排队动画 [打印本页]

作者: 菜鸟教程小白    时间: 2022-12-12 09:54
标题: iphone - 使用 block 排队动画

在我的 didSelectRowAtIndexPath 方法中,当用户选择一个单元格时,我会调用 [self dismissView]; 以便在 View 已呈现时关闭该 View 。这显然不是非常理想的,并且它在没有动画的情况下覆盖了 presentView 方法。有一个更好的方法吗?或者至少让它等待 View 完成动画而不使用 NSTimer。

- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath;
{
    [self dismissView];

// Do xyz...

[self presentView:twitterLinksView];

那么..

- (void)presentViewid)sender
{
    twitterLinksView.frame = CGRectMake(0, (self.view.frame.size.height + viewHeight), 320, 300);


    [UIView animateWithDuration:0.60f animations:^{


        CGRect twitterLinkFrame   = self.twitterLinksView.frame;
        twitterLinkFrame.origin.y = (self.view.frame.size.height - viewHeight);

        twitterLinksView.frame = twitterLinkFrame;
    }];
}

- (void)dismissView
{

    [UIView animateWithDuration:0.75f animations:^{

        CGRect twitterLinkFrame   = self.twitterLinksView.frame;
        twitterLinkFrame.origin.y = (self.view.frame.size.height + viewHeight);

        self.twitterLinksView.frame = twitterLinkFrame;
    }];
}



Best Answer-推荐答案


[UIView animateWithDuration:1. animations:^{

     //firstAnimationBlock

    } completion:^(BOOL finished){
        [UIView animateWithDuration:1. animations:^{

//animations in this block will be called after firstAnimationBlock has expired
        }];
    }];

据我了解,您想要一个接一个地触发 2 个动画。这段代码( block 内的 block )使这个

这部分是经过编辑的: 好的,现在你可以尝试这样写

- (void)tableViewUITableView *)tableView didSelectRowAtIndexPathNSIndexPath *)indexPath;
{
    [self dismissView];

// Do xyz...

[self performSelectorselector(presentView withObject:twitterLinksView afterDelay:0.75];

//[self presentView:twitterLinksView];
}

关于iphone - 使用 block 排队动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15668375/






欢迎光临 OGeek|极客世界-中国程序员成长平台 (http://ogeek.cn/) Powered by Discuz! X3.4