【问题标题】:Why would my app draw incorrectly on an iPhone 3G when downloaded from the App Store?从 App Store 下载时,为什么我的应用程序在 iPhone 3G 上绘制不正确?
【发布时间】:2011-12-21 14:38:13
【问题描述】:

我有一个应用程序在设备上的调试模式下运行良好。我将应用程序发送到 App Store,它运行良好,但 iPhone 3G 除外。

我的测试(调试)设备是 iPhone 3G,它在调试时工作得很好,但是当我下载该应用程序并通过 App Store 安装它时,它在我的 iPhone 上也不能工作。

我在代码中有一些 NSLog,并认为这可能是问题所在,但即使在删除 NSLog 之后,iPhone 3G 上也会发生同样的事情。

问题是我正在使用以下代码:

- (void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event {
    mouseSwiped = YES;

    UITouch *touch = [touches anyObject];   
    CGPoint currentPoint = [touch locationInView:self.view];
    currentPoint.y -= 20;


    UIGraphicsBeginImageContext(self.view.frame.size);
    [drawImage.image drawInRect:CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height)];
    CGContextSetLineCap(UIGraphicsGetCurrentContext(), kCGLineCapRound);
    CGContextSetLineWidth(UIGraphicsGetCurrentContext(), 5.0);
    CGContextSetRGBStrokeColor(UIGraphicsGetCurrentContext(), 1.0, 0.0, 0.0, 1.0);
    CGContextBeginPath(UIGraphicsGetCurrentContext());
    CGContextMoveToPoint(UIGraphicsGetCurrentContext(), lastPoint.x, lastPoint.y);
    CGContextAddLineToPoint(UIGraphicsGetCurrentContext(), currentPoint.x, currentPoint.y);
    CGContextStrokePath(UIGraphicsGetCurrentContext());
    drawImage.image = UIGraphicsGetImageFromCurrentImageContext();
    UIGraphicsEndImageContext();

    lastPoint = currentPoint;

}

在 iPhone 3G 上,这并不正确。它只是制作水平线。这在其他设备上运行良好。

这里可能出了什么问题?

【问题讨论】:

    标签: iphone ios xcode cocoa-touch app-store


    【解决方案1】:

    Xcode 4.2 中的 LLVM 编译器存在一个已知错误,在 ARMv6 架构上使用 CGPoints 等时会导致错误结果。这在this thread on the Apple Developer Forums 中有详细说明。 ARMv6 用于 iPhone 3G S 之前的设备(例如您的 iPhone 3G),因此您会在那里看到它。

    该错误与为您的应用程序的 ARMv6 版本生成不正确的 Thumb 代码有关。我在我的回答 here 中描述了如何选择性地为旧架构禁用 Thumb(同时保留未受影响的 ARMv7 版本的性能)。

    有人说 Xcode 4.2.1 有一个固定版本的 LLVM 可以解决这个问题,但我无法确认。阅读 gparker 在this Apple Developer Forum thread 末尾附近的评论,看看在哪里此问题已修复。

    【讨论】:

    • 非常感谢!这是帮助我的答案!我将 armv6 和 armv7 用于调试和发布,它适用于二进制文件!再次感谢!
    • 对不起,我是新来的所以我不知道如何接受'直到现在:)
    【解决方案2】:

    我也遇到过类似的问题。我发现很多这样的麻烦是由 Xcode 为 armv6 架构进行的错误优化引起的。

    在“构建设置”->“Apple LLMV 编译器 3.0 - 代码生成”->“优化级别”中,您肯定有发布版本的优化设置。更改它并将其设置为 NONE,因为肯定是 Debug 版本。

    就是这样。如果问题是我认为的那样,那么这就是解决方案。您可以测试此解决方案构建 Adhoc 应用程序。

    【讨论】:

    • 感谢您的提示!我会试试看,让你知道!
    • 我在使用 armv6 代码时遇到了同样的问题。在 Xcode 中,您可以为每个文件设置优化级别,因此您不必禁用整个应用程序的优化。 'Your Target' -> 'Build Phases' -> 'Compile Sources' 你有一个 'Compiler Flags' 列,只需在有问题的文件上将其设置为 -O0。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-12-14
    • 1970-01-01
    • 2019-12-04
    • 2014-04-15
    • 2010-10-28
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多