“iPhone加载视图”;“幻灯片效果”;

“iPhone加载视图”;“幻灯片效果”;,iphone,objective-c,uiview,core-animation,uiviewanimation,Iphone,Objective C,Uiview,Core Animation,Uiviewanimation,我想实现的是,当你在我的应用程序中请求一些东西时(如按下按钮或其他),我希望它出现一个小矩形,上面写着“加载…”,加载完成后,它会消失,并产生“向上滑动效果”。我制作了一个简单的模型来很好地描述我想要实现的目标。你有什么提示给我吗?谢谢 注意:我不希望出现拉刷新效果(加载视图显示时没有屏幕滚动,例如在您发送评论时显示) 更新: 我试过Cirrostratus密码: - (IBAction)displayLoadingScreen:(id)sender { NSLog(@"pressed

我想实现的是,当你在我的应用程序中请求一些东西时(如按下按钮或其他),我希望它出现一个小矩形,上面写着“加载…”,加载完成后,它会消失,并产生“向上滑动效果”。我制作了一个简单的模型来很好地描述我想要实现的目标。你有什么提示给我吗?谢谢

注意:我不希望出现拉刷新效果(加载视图显示时没有屏幕滚动,例如在您发送评论时显示)

更新:

我试过Cirrostratus密码:

- (IBAction)displayLoadingScreen:(id)sender
{
    NSLog(@"pressed");
    UIView *loadingView = [[UIView alloc] init];
    loadingView.frame = CGRectMake(0,-40,320,40);
    [loadingView setBackgroundColor:[UIColor blueColor]];
    [self.view addSubview:loadingView];
    //animate in within some method called when loading starts
    [UIView animateWithDuration:1.0
                     animations:^{ 
                         loadingView.frame = CGRectMake(0,0,320,40);
                     } 
                     completion:^(BOOL finished) {
                     }];
    for (int i = 0; i < 10000; i++) {
        NSLog(@"%d", i);
    }
    //animate out within some method called when loading ends
    [UIView animateWithDuration:1.0
                     animations:^{ 
                         loadingView.frame = CGRectMake(0,-40,320,40);
                     } 
                     completion:^(BOOL finished){


                     }];
}

我要做的是在其他视图前面添加一个视图,并使用所需的加载设计

然后,当加载完成时(使用通知或仅调用视图的一个函数),用这种动画将其向上滑动:

[UIView animateWithDuration:0.3
                              delay:0
                            options:UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             //change the frame to make the view go out of the screen
                         }
                         completion:^(BOOL finished){
                             //do whatever you want with the view (release it for instance)
                         }];

您可以在微调器的帮助下完成此操作,否则您只需查看并设置动画及其坐标,当您单击任何对象时,它将在您的视图中弹出,加载完成后,您必须为您的弹出视图设置“-”坐标(帧),它将使您……

尝试阅读
UIAnimation
class(并使用QuartzCore框架)或者,如果你想使用幻灯片来更新像脸谱网那样的特性,考虑使用<代码> EGOTableViewPullRefresh <代码>。在我的回答中,我告诉你把这些动画放在不同的方法中,一个在加载开始时被调用,另一个在加载结束时被调用。在动画完成之前,循环执行,因为动画需要1秒。执行,这是在其他代码继续运行时完成的。因此,重述一下,两个动画不是在同一个方法中进行的。在加载实际开始时调用一个,在加载实际完成时调用另一个,一切都会好起来的。感谢您的耐心,但我发现它对我不起作用。请参阅我的新更新。为什么第一个执行的语句不起作用他
sleep
而不是我在动画中的第一张幻灯片?如果你实际上加载的数据与使用睡眠不同。你永远不应该在iPhone程序中真正使用睡眠。拿出睡眠并这样做:[UIView animateWithDuration:1.0 animations:^{loadingView.frame=CGRectMake(0,0320,40)}完成:^(BOOL完成){[UIView animateWithDuration:1.0动画:^{loadingView.frame=CGRectMake(0,-40320,40);}完成:^(BOOL完成){}];];我使用
睡眠
进行测试。动画效果很好,但我希望视图滑入,停留几秒钟(请求时间),然后在请求完成后滑出。想法?
loadingView.frame = CGRectMake(0,-40,320,40);
[loadingView setBackgroundColor:[UIColor blueColor]];
[self.view addSubview:loadingView];
//animate in within some method called when loading starts
[UIView animateWithDuration:1.0
                 animations:^{ 
                     loadingView.frame = CGRectMake(0,0,320,40);
                 } 
                 completion:^(BOOL finished){


                 }];
//animate out within some method called when loading ends
[UIView animateWithDuration:1.0
                 animations:^{ 
                     loadingView.frame = CGRectMake(0,-40,320,40);
                 } 
                 completion:^(BOOL finished){


                 }];
[UIView animateWithDuration:0.3
                              delay:0
                            options:UIViewAnimationOptionAllowUserInteraction
                         animations:^{
                             //change the frame to make the view go out of the screen
                         }
                         completion:^(BOOL finished){
                             //do whatever you want with the view (release it for instance)
                         }];