为什么XCode存档的行为与iPhone上的XCode构build/运行不同

我有一个在XCode 4上开发的iPhone应用程序。它在以下环境中正常工作:

  1. iPhone模拟器(iOS版本5)
  2. iOS 5设备(从存档执行)
  3. iOS 5设备(从XCode构build执行)
  4. iOS 4设备(从XCode构build执行)
  5. iOS 3设备(从XCode构build执行)

但是,当我将iOS 5中的存档放在iOS 3或4设备上时,这很有趣。 尽pipe在同一个设备上从XCode运行时,完全相同的代码工作正常。

当我说它有趣的时候,它是在错误的轴上滑动UIViewanimation。 在做animation之前,我在UIView上执行了一个旋转转换。 但是,即使在iOS 3和4设备上,直接从XCode运行也可以正常工作。 它只是在档案中进行操作,仅适用于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; } 

animation是由:

 // 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]; 

一切运行良好。 有什么想法吗?

尝试closures编译器优化。

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

closures拇指也可以帮助你解决这个问题,你可以去你的构build设置,并将鼠标hover在“其他C标志”选项上。 单击此选项右侧出现的小加号button,为ARMv6体系结构添加条件。 再次这样做,为ARMv7架构创build一个。 在ARMv6架构下,添加-mno-thumb的额外编译器标志。

Thumb关闭ARMv6

代码看起来不错。 我在这里看到的唯一问题是:rect.origin = CGPointMake(VIEW_IMAGE_X_POS,myView.contentSize.height – 108);

尝试硬编码myView.contentSize.height值。 根据更新的当前设备方向,视图/窗口可能不会返回contentSize。