iPhone 4 上的动画与模拟器不同
我在 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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
可能就像罗曼提到的那样。确保您的文件名正确。
文件名在真实设备上区分大小写,但在模拟器上不区分大小写。
Probably like Roman mentioned. Make sure your file name is correct.
The filename is case sensitive on real devices but not on the simulator.
问题是该图像不在项目的当前版本中,而是在其先前版本中,因此模拟器以某种方式链接了项目先前版本中的图像,但在真实设备上却没有存在。
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.