iOS   发布时间:2022-05-04  发布网站:大佬教程  code.js-code.com
大佬教程收集整理的这篇文章主要介绍了为什么XCode存档的行为与iPhone上的XCode构建/运行不同大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。

概述

我有一个在XCode 4上开发的iPhone应用程序.它在以下环境中正常工作: > iPhone模拟器(iOS版本5) > iOS 5设备(从Archive执行) > iOS 5设备(从XCode构建执行) > iOS 4设备(从XCode构建执行) > iOS 3设备(从XCode版本执行) 但是,当我将iOS 5中运行的存档放在iOS 3或4设备上时,它很有趣.从同一设备上的XCode运行时,
我有一个在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];

其他一切都很好.有什么想法吗?

解决方法

尝试关闭编译器优化.

编译发布版本时,旧iOS 3.x和4.x ARMv6设备上的UI出现问题.我不知道为什么,但关闭编译器优化将有所帮助.

关闭Thumb也可以帮助您解决此问题,您可以转到构建设置并将鼠标悬停在“其他C标志”选项上.单击此选项右侧显示的小加号按钮,为ARMv6体系结构添加条件.再次执行此操作为ARMv7体系结构创建一个.在ARMv6体系结构下,添加-mno-thumb的额外编译器标志.

大佬总结

以上是大佬教程为你收集整理的为什么XCode存档的行为与iPhone上的XCode构建/运行不同全部内容,希望文章能够帮你解决为什么XCode存档的行为与iPhone上的XCode构建/运行不同所遇到的程序开发问题。

如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。

本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。