containsPoint:用于 UIBezierPath 崩溃 [英] containsPoint: for UIBezierPath crashes
问题描述
我正在将 SVG 文件解析为 UIBezierPath
.我想知道 CGPoint
是在 UIBezierPath
内部还是外部.为此,我使用 containsPoint:
.当我在模拟器中运行它时,一切正常(几乎!).当我在 iPad 设备上运行它时,它会在某些路径和点上崩溃.在调用 containsPoint:
之前,我在每个 UIBezierPath
上调用 closePath
.
I'm parsing a SVG file to UIBezierPath
. I'd like to know whether a CGPoint
is inside or outside the UIBezierPath
. To do this I use containsPoint:
. When I run this in the simulator everthing works fine (almost!). When I run it a iPad device it crashes on some paths and points. I'm calling closePath
on every UIBezierPath
before I call containsPoint:
.
这里有一些路径和点,这会导致它崩溃(我随机化了这些点,所以可能会有更多的崩溃点):
Here are some paths and points, which makes it crash (I randomize the points, so there might be more crash points):
Crash Points: (659.0, 444.0), (659.0, 443.0)
SVG Path: M661 446 c1 -1 3 -1 4 -1 1 -1 2 -2 2 -4 0 -2 0 -2 -2 -2 0 1 -2 1 -3 1 -2 0 -3 1 -3 2 0 1 0 2 0 3 0 0 1 1 2 1z
Crash Points: (533.0, 458.0), (533.0, 457.0)
SVG Path: M535 460 c0 0 1 -1 1 -2 1 -2 0 -3 -1 -3 0 0 -1 0 -2 1 0 1 0 2 0 3 1 0 1 1 2 1z
我不知道它为什么会崩溃.对我来说,无论它得到什么路径或点,它都应该返回 YES
或 NO
.
I can't figure out why it crashes. To me it should return YES
or NO
no matter what path or point it gets.
为什么会崩溃?:-(
推荐答案
事实证明崩溃是框架中的一个错误.此答案提供了另一种确定点是否在UIBezierPath
内的方法.
It turns out the crash is a bug in the framework. This answer provides another way to determine whether a point is inside a UIBezierPath
.
这篇关于containsPoint:用于 UIBezierPath 崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!