iPhone 4 上的动画与模拟器不同

发布于 2025-01-08 07:40:03 字数 827 浏览 3 评论 0原文

我在 XCode 4 上尝试了这段代码,然后它可以工作,但它甚至没有出现在 iphone 4 真手机上。

    UIImage *myimage = [UIImage imageNamed:@"2-2.PNG"];
    UIImageView *myimageView =[[UIImageView alloc] initWithImage:myimage];
    myimageView.frame = CGRectMake(15, 15, 20, 20);

    CABasicAnimation *animation = nil; 
    CATransform3D transform;

    animation = [CABasicAnimation animationWithKeyPath:@"transform"];

    transform = CATransform3DMakeRotation(1.57f, 0.0f, 1.0f, 0.0f); 
    NSValue* value = [NSValue valueWithCATransform3D:transform]; 
    [animation setToValue:value];
    [animation setAutoreverses:YES]; 
    [animation setDuration:0.5f];
    [animation setRepeatCount:2.0];
    [[myimageView layer] addAnimation:animation forKey:@"180"];

    [self.view addSubview:myimageView];

有什么帮助我应该做什么才能使它在真正的手机上运行吗?

I tried this code on XCode 4 then it works, but it doesn't even appear on iphone 4 real handset.

    UIImage *myimage = [UIImage imageNamed:@"2-2.PNG"];
    UIImageView *myimageView =[[UIImageView alloc] initWithImage:myimage];
    myimageView.frame = CGRectMake(15, 15, 20, 20);

    CABasicAnimation *animation = nil; 
    CATransform3D transform;

    animation = [CABasicAnimation animationWithKeyPath:@"transform"];

    transform = CATransform3DMakeRotation(1.57f, 0.0f, 1.0f, 0.0f); 
    NSValue* value = [NSValue valueWithCATransform3D:transform]; 
    [animation setToValue:value];
    [animation setAutoreverses:YES]; 
    [animation setDuration:0.5f];
    [animation setRepeatCount:2.0];
    [[myimageView layer] addAnimation:animation forKey:@"180"];

    [self.view addSubview:myimageView];

any help what I should do to make it works on real handset ?

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

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

发布评论

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

评论(2

悟红尘 2025-01-15 07:40:03

可能就像罗曼提到的那样。确保您的文件名正确。

文件名在真实设备上区分大小写,但在模拟器上不区分大小写。

Probably like Roman mentioned. Make sure your file name is correct.

The filename is case sensitive on real devices but not on the simulator.

七堇年 2025-01-15 07:40:03

问题是该图像不在项目的当前版本中,而是在其先前版本中,因此模拟器以某种方式链接了项目先前版本中的图像,但在真实设备上却没有存在。

The problem was that the image wasn't in the current version of the project, but it was on a previous version of it, so that somehow the simulator linked the image from the previous version of my project but on real device it wasn't exist.

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