从 App Store 下载后,为什么我的应用程序在 iPhone 3G 上绘制不正确?

发布于 2024-12-22 11:14:26 字数 1381 浏览 2 评论 0原文

我有一个在设备上的调试模式下运行良好的应用程序。我将该应用程序发送到 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 上绘制不正确。它只是制作水平线。这在其他设备上运行良好。

这里可能出了什么问题?

I have an app that works fine in the debug mode on the device. I sent the app to the App Store and it works fine, except for iPhone 3G.

My test(debug) device is an iPhone 3G and it works just fine in debug, but when I downloaded the app and installed it via the App Store, it didn't work on my iPhone as well.

I had some NSLogs in the code and thought that that might be the problem, but even after the removal of NSLog, the same thing happens on iPhone 3G.

The problem is that I'm using the following code:

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

}

and on an iPhone 3G this does not draw right. It just makes horizontal lines. This works fine on other devices.

What could be going wrong here?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

撧情箌佬 2024-12-29 11:14:26

Xcode 4.2 中的 LLVM 编译器存在一个已知错误,该错误会导致在 ARMv6 架构上使用 CGPoints 等时产生不正确的结果。 Apple 开发者论坛上的此帖子对此进行了详细介绍。 ARMv6 用于 iPhone 3G S 之前的设备(例如 iPhone 3G),因此您会在那里看到它。

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

有人说 Xcode 4.2.1 有一个固定版本的 LLVM 可以解决这个问题,但我无法确认这一点。阅读 gparker 在 此 Apple 开发者论坛帖子 查看此问题已在何处修复。

There is a known bug with the LLVM compiler in Xcode 4.2 that leads to incorrect results when using CGPoints, etc. on the ARMv6 architecture. This is detailed in this thread on the Apple Developer Forums. ARMv6 is what is used for pre-iPhone 3G S devices (such as your iPhone 3G), so that's why you'd see it there.

The bug is related to incorrect Thumb code generation for the ARMv6 builds of your application. I describe how to selectively disable Thumb for just that older architecture (while preserving performance on the unaffected ARMv7 build) in my answer here.

Some people have said that Xcode 4.2.1 has a fixed version of LLVM which addresses this, but I can't confirm that. Read gparker's comment near the end of this Apple Developer Forum thread to see where this has been fixed.

情仇皆在手 2024-12-29 11:14:26

我也遇到过类似的问题。我发现很多此类问题都是由Xcode针对armv6架构进行的有bug的优化引起的。

在“构建设置”-> 《Apple LLMV Compiler 3.0 - 代码生成》-> “优化级别”您肯定有针对发布版本的优化设置。更改它并将其设置为 NONE,因为调试版本是肯定的。

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

I have suffered similar issues. I discovered that a lot of that kind of troubles are originated by a buggy optimization made by Xcode for armv6 architecture.

In "Build Settings" -> "Apple LLMV Compiler 3.0 - code generation" -> "Optimization Level" you surely have an optimization setting for Release version. Change it and set it to NONE as Debug version is for sure.

That is all. If the problem is what I think it is, then that is the solution. You can test this solution building Adhoc app.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文