ios - 在 iOS 中使用多点触控绘图撤消
<p><p>我在写作时使用多点触控,所以基本上我正在做的是,我正在用手支持写作,因为通常,它是如何用户权限的,我点击了这个链接 <a href="https://stackoverflow.com/questions/20853765/how-to-ignore-certain-uitouch-points-in-multitouch-sequence" rel="noreferrer noopener nofollow">How to ignore certain UITouch Points in multitouch sequence</a> </p>
<p>一切正常,但是当我用手触摸屏幕书写时,它们的撤消有些问题,否则它工作正常。</p>
<p>下面是我的代码</p>
<pre><code>-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* topmostTouch = self.trackingTouch;
for (UITouch *touch in touches)
{
ctr = 0;
touchStartPoint1 = ;
;
;
;
if(!topmostTouch || .y > touchStartPoint1.y)
{
topmostTouch = touch;
pts = touchStartPoint1;
}
}
if (self.trackingTouch != nil && self.trackingTouch != topmostTouch)// !)
{
;
}
self.trackingTouch = topmostTouch;
}
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
if(self.trackingTouch== nil)
{
return;
}
CGPoint p = ;
ctr++;
pts = p;
if (ctr == 4)
{
pts = midPoint(pts, pts);
self.currentPath = [ init];
;
self.currentPath.pathWidth = ;
];
controlPoint1:pts controlPoint2:pts];
CGPathRef cgPath = self.currentPath.path.CGPath;
mutablePath = CGPathCreateMutableCopy(cgPath);
;
;
pts = pts;
pts = pts;
ctr = 1;
}
}
-(void)touchesEnded:(NSSet *)touches withEvent:(UIEvent *)event
{
for (UITouch *touch in touches)
{
if(touch == self.trackingTouch)
{
];
}
}
}
-(void)undoButtonClicked
{
NSMutableArray *undoArray = ;
NSLog(@"%@",undoArray);
;
;
m_drawStep = UNDO;
;
}
- (void)drawRect
{
I have different cases here, I am showing Of Undo
for(int i = 0; i<;i++)
{
NSMutableArray *undoArray = ;
NSLog(@"%@",undoArray);
for(int i =0; i<;i++)
{
DrawingPath *drawPath = ;
GPathRef path = drawPath.path.CGPath;
mutablePath = CGPathCreateMutableCopy(path);
//Draw into CgLayer
}
}
}
</code></pre>
<p>这是更好地理解我的问题的图像,我首先写了这个</p>
<p> <img src="/image/4iF7P.png" alt="enter image description here"/> </p>
<p> <img src="/image/spQtO.png" alt="After clicking on undo Once"/> </p>
<p>单击一次撤消后,您可以在上方看到,其他部分已撤消,而不是最后一部分。所以在这方面我需要你的帮助。</p></p>
<br><hr><h1><strong>Best Answer-推荐答案</ strong></h1><br>
<p><p>m_redoArray 似乎是大爸爸,你从中汲取灵感的那个。我不明白你为什么在'touchesBegan ...'中清空它,这些数组中的一个肯定必须保持不变,否则你会从绘图开始一直丢弃东西,不是吗? </p>
<p>在我看来,这就是您在此处的示例中删除“ hell ”的方式..</p></p>
<p style="font-size: 20px;">关于ios - 在 iOS 中使用多点触控绘图撤消,我们在Stack Overflow上找到一个类似的问题:
<a href="https://stackoverflow.com/questions/21935064/" rel="noreferrer noopener nofollow" style="color: red;">
https://stackoverflow.com/questions/21935064/
</a>
</p>
页:
[1]