PNG图像序列播放问题

发布于 2024-08-02 14:04:58 字数 1069 浏览 2 评论 0原文

好的,我有一个按钮,按下该按钮后,应该动画/播放 png 图像序列。

我的问题是 -

  • 我按下按钮(按钮 A)并且播放图像序列 - 这很好!
  • 但当我再次按下(按钮A)时,什么也没有发生。 - 坏的。
  • 但是然后...如果我第三次按下(按钮 A)- 图像序列就会播放。

所以基本上,图像序列仅在我按下按钮时每秒播放一次?...我不知道是什么原因造成的?

另一种情况可能会为您提供有关问题的线索 -

  • 我按下按钮(按钮 A),一切正常
  • 我按下另一个按钮(按钮 B),它会执行不同的操作
  • 然后我按下(按钮A) 再次,一切正常。

看来,图像序列只有在按下(按钮 A)之间发生其他事情时才会播放?

有什么想法吗?

这是代码...视图“viewDidLoad”有 [self loadAnimX01];

    - (void) loadAnimX01 {

    x01 = [[UIImageView alloc] initWithFrame:CGRectMake(35.0f, 112.0f,70.0f, 115.0f)];
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 1; i <= 15; i++) 
        [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"pipe01_%02d.png",i]]];
    x01.animationImages = array;
    x01.animationDuration = 0.7;
    x01.animationRepeatCount = 1;
    [self.view addSubview:x01];
    [x01 release];
}

- (IBAction)pX01 {
    [x01 startAnimating];
}

谢谢!

Ok, I have a button that, when pressed, should animate/play a png image sequence.

My problem is -

  • I press the button (button A) and the image sequence plays - which is good!
  • but then I press (button A) again and nothing happens. - bad.
  • but then... if I press (button A) a third time - the image sequence plays.

So basically, the image sequence only plays every second time I press the button?...I can't think what could be causing that?

Another scenario which might give you clues to the problem -

  • I press the button (button A) and everything works fine
  • I press a different button (button B) and it does its different thing
  • Then I press (button A) again and everything works fine.

So it seems, the image sequence only plays if something else happens in between (button A) presses?

Any ideas?

Here is the code... The views "viewDidLoad" has [self loadAnimX01];

    - (void) loadAnimX01 {

    x01 = [[UIImageView alloc] initWithFrame:CGRectMake(35.0f, 112.0f,70.0f, 115.0f)];
    NSMutableArray *array = [NSMutableArray array];
    for (int i = 1; i <= 15; i++) 
        [array addObject:[UIImage imageNamed:[NSString stringWithFormat:@"pipe01_%02d.png",i]]];
    x01.animationImages = array;
    x01.animationDuration = 0.7;
    x01.animationRepeatCount = 1;
    [self.view addSubview:x01];
    [x01 release];
}

- (IBAction)pX01 {
    [x01 startAnimating];
}

Thanks!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

飞烟轻若梦 2024-08-09 14:04:58

好吧,我想出了一个解决方案。但我还是无法理解!?

  • 我必须检查序列是否正在播放
  • 然后停止序列
  • 然后播放它。

这使得每次按下按钮时都会播放图像序列

如果有人能告诉我为什么我必须这样做...请让我知道

这是我的解决方案

- (IBAction)pX01{
if ([x01 isAnimating]) { 
    [x01 stopAnimating];
}
[x01 startAnimating];

}

谢谢!

Well i figured out a solution. But I still cant make sense of it!?

  • I have to check to see if the sequence is playing
  • Then stop the sequence
  • Then play it.

This makes the the image sequence play every time I press the button

If anyone could tell my why my I have to do this... please let me know

Here is my solution

- (IBAction)pX01{
if ([x01 isAnimating]) { 
    [x01 stopAnimating];
}
[x01 startAnimating];

}

Thanks!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文