为什么XCode存档的行为与iPhone上的XCode构建/运行不同 [英] Why is XCode archive acting different than XCode build/run on iPhone

查看:76
本文介绍了为什么XCode存档的行为与iPhone上的XCode构建/运行不同的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I have an app for the iPhone developed on XCode 4. It works correctly in the following environments:


  1. iPhone模拟器(iOS版) 5)

  2. iOS 5设备(从存档执行)

  3. iOS 5设备(从XCode版本执行)

  4. iOS 4设备(从XCode构建执行)

  5. iOS 3设备(从XCode构建执行)

  1. iPhone Simulator (iOS version 5)
  2. iOS 5 device (executed from Archive)
  3. iOS 5 device (executed from XCode build)
  4. iOS 4 device (execute from XCode build)
  5. iOS 3 device (executed from XCode build)

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

However, when I put the archive that works in iOS 5 on a iOS 3 or 4 device it acts funny. The exact same code works fine when run from XCode on the same device though.

当我说它表现得很有趣时,它会在错误的轴上设置滑动UIView的动画。在我为它制作动画之前,我确实在UIView上执行了旋转变换。但同样,它直接从XCode运行时工作正常,即使在iOS 3和4设备上也是如此。它仅在存档中起作用,仅适用于iOS 3和4.该存档在iOS 5中运行良好。

When I say it acts funny, it is animating a sliding UIView in the wrong axis. I do perform a rotation transformation on the UIView before I animate it though. But again, it works fine when run directly from XCode, even on iOS 3 and 4 devices. It is only acting up in the archive and only for iOS 3 and 4. The archive works fine in iOS 5.

旋转是通过辅助中的静态调用完成的class:

The rotation is done by a static call in a helper class:

+ (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];

其他一切正常。有什么想法?

Everything else runs fine. Any thoughts?

推荐答案

尝试关闭编译器优化。

Try to turn off compiler optimizations.

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

Something is going wrong with UI on old iOS 3.x and 4.x ARMv6 devices when compiling a release build. I have no idea why, but turning off compiler optimizations will help.

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

Turning off Thumb may also help you with this issue, you can go to your build settings and mouse over the "Other C Flags" option. Click on the little plus button that appears to the right of this option and add a condition for the ARMv6 architecture. Do this again to create one for the ARMv7 architecture. Under the ARMv6 architecture, add the extra compiler flag of -mno-thumb.

这篇关于为什么XCode存档的行为与iPhone上的XCode构建/运行不同的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆