gpt4 book ai didi

iphone - 为什么 XCode 存档与 XCode 在 iPhone 上构建/运行不同

转载 作者:可可西里 更新时间:2023-11-01 05:47:19 26 4
gpt4 key购买 nike

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

  1. iPhone 模拟器(iOS 版本 5)
  2. iOS 5 设备(从存档执行)
  3. iOS 5 设备(从 XCode 构建执行)
  4. iOS 4 设备(从 XCode 构建执行)
  5. 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 也可以帮助您解决这个问题,您可以转到build设置并将鼠标悬停在“其他 cflags”选项上。单击出现在该选项右侧的小加号按钮,并为 ARMv6 架构添加一个条件。再次执行此操作,为 ARMv7 架构创建一个。在ARMv6架构下,添加-mno-thumb的额外编译标志。

Thumb turned off for ARMv6

关于iphone - 为什么 XCode 存档与 XCode 在 iPhone 上构建/运行不同,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8813711/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com