我有一个在XCode 4上开发的iPhone应用程序.它在以下环境中正常工作:
> iPhone模拟器(iOS版本5)
> iOS 5设备(从Archive执行)
> iOS 5设备(从XCode构建执行)
> iOS 4设备(从XCode构建执行)
> iOS 3设备(从XCode版本执行)
但是,当我将iOS 5中运行的存档放在iOS 3或4设备上时,它很有趣.从同一设备上的XCode运行时,完全相同的代码工作正常.
当我说它表现得很有趣时,它会在错误的轴上动画滑动的UIView.在我为它制作动画之前,我确实在UIView上执行了旋转变换.但同样,它直接从XCode运行时工作正常,即使在iOS 3和4设备上也是如此.它仅在存档中起作用,仅适用于iOS 3和4.该存档在iOS 5中运行良好.
旋转是通过辅助类中的静态调用完成的:
+ (UIImage*)rotateImage:(UIImage *)image { CGRect bnds = CGRectZero; UIImage* copy = nil; CGContextRef ctxt = nil; CGImageRef imag = image.CGImage; CGRect rect = CGRectZero; CGAffineTransform tran = CGAffineTransformIdentity; rect.size.width = CGImageGetWidth(imag); rect.size.height = CGImageGetHeight(imag); bnds = rect; bnds = swapWidthAndHeight(bnds); tran = CGAffineTransformMakeTranslation(rect.size.height,0.0); tran = CGAffineTransformRotate(tran,M_PI / 2.0); UIGraphicsBeginImageContext(bnds.size); ctxt = UIGraphicsGetCurrentContext(); CGContextScaleCTM(ctxt,-1.0,1.0); CGContextTranslateCTM(ctxt,-rect.size.height,0.0); CGContextConcatCTM(ctxt,tran); CGContextDrawImage(UIGraphicsGetCurrentContext(),rect,imag); copy = UIGraphicsGetimageFromCurrentimageContext(); UIGraphicsEndImageContext(); return copy; }
动画由:
// The first image should fall from top. CGRect rect = boardView.frame; rect.origin = CGPointMake(VIEW_IMAGE_X_POS,0); boardView.frame = rect; [myView addSubview:boardView]; // The starting image comes down. Then passes control to the next animation routine for the clones. [UIView beginAnimations:@"addStartingImage" context:boardView]; [UIView setAnimationDuration:1.2]; [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(startingImageDidStop:finished:context:)]; // Add the new image rect = boardView.frame; rect.origin = CGPointMake(VIEW_IMAGE_X_POS,myView.contentSize.height - 108); boardView.frame = rect; // End the animation [UIView commitAnimations];
其他一切都很好.有什么想法吗?
解决方法
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。