Delphi iOS zoom+;同时平移(两个手指不能同时离开屏幕)
我有以下代码:Delphi iOS zoom+;同时平移(两个手指不能同时离开屏幕),ios,delphi,Ios,Delphi,我有以下代码: case EventInfo.GestureID of igiZoom: begin if (not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags)) then begin if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) then
case EventInfo.GestureID of
igiZoom:
begin
if
(not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags))
then
begin
if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) then
begin
W := LImage.Width + 2 * ((EventInfo.Distance - FMapsLastDistanceZoom) / 3);
H := LImage.Height + 2 * ((EventInfo.Distance - FMapsLastDistanceZoom) / 3);
if
(W < layoutMapsContent.Width)
or
(H < layoutMapsContent.Height)
then
begin
W := layoutMapsContent.Width;
H := layoutMapsContent.Height;
end
;
LImage.Width := W;
LImage.Height := H;
end
;
FMapsLastDistanceZoom := EventInfo.Distance;
end
;
end
;
igiPan:
begin
if
(not(TInteractiveGestureFlag.gfEnd in EventInfo.Flags))
then
begin
if (not(TInteractiveGestureFlag.gfBegin in EventInfo.Flags)) then
begin
LImage.Position.X := LImage.Position.X + (EventInfo.Location.X - FMapsLastPositionPan.X);
LImage.Position.Y := LImage.Position.Y + (EventInfo.Location.Y - FMapsLastPositionPan.Y);
end
;
FMapsLastPositionPan.X := EventInfo.Location.X;
FMapsLastPositionPan.Y := EventInfo.Location.Y;
end
;
end
;
igiDoubleTap:
begin
UpdateMapsPosition;
end
;
end;
的案例EventInfo.GestureID
图像缩放:
开始
如果
(不是(EventInfo.Flags中的TInteractiveGestureFlag.gfEnd))
然后
开始
如果(不是(在EventInfo.Flags中的TInteractiveGestureFlag.gfBegin),则
开始
W:=LImage.Width+2*((EventInfo.Distance-fmapslastdancezoom)/3);
H:=LImage.Height+2*((EventInfo.Distance-fmapslastdancezoom)/3);
如果
(W<布局图内容宽度)
或
(H<布局图内容高度)
然后
开始
W:=布局图内容宽度;
H:=布局图内容高度;
终止
;
极限宽度:=W;
极限高度:=H;
终止
;
FMapsLastDistanceZoom:=EventInfo.Distance;
终止
;
终止
;
伊吉潘:
开始
如果
(不是(EventInfo.Flags中的TInteractiveGestureFlag.gfEnd))
然后
开始
如果(不是(在EventInfo.Flags中的TInteractiveGestureFlag.gfBegin),则
开始
LImage.Position.X:=LImage.Position.X+(EventInfo.Location.X-FMapsLastPositionPan.X);
LImage.Position.Y:=LImage.Position.Y+(EventInfo.Location.Y-FMapsLastPositionPan.Y);
终止
;
FMapsLastPositionPan.X:=EventInfo.Location.X;
FMapsLastPositionPan.Y:=EventInfo.Location.Y;
终止
;
终止
;
双重抽头:
开始
更新位置;
终止
;
终止
但是,由于缩放使用两个手指,如果一个手指稍微先于另一个手指移动,平移有时会出错(图像平移时跳到执行缩放的“最后一个”手指)
有什么办法可以解决这个问题吗?我只有一个单触式显示器,所以我无法真正测试多触式手势。你应该试着找出事情发生的顺序:(igiZoom/[gfBegin]),(igiZoom/[]),(igiZoom/[gfEnd]),(igiPan/[gfBegin]),(igiPan/[gfindivity]),(igiPan/[gfEnd])。这就是我所期望的。是按这种顺序发生的吗?除此之外,您还可以自己编写代码:缩放和平移手势的
EventInfo.Location
是什么?如果它们是相同的,你可以通过这种方式来识别这种情况。我不确定我读到的内容是否正确,但问题是我无法区分:1)当松开第一根手指时,会生成一个正常的igiPan(没有gfEnd/gfBegin)事件。2) 释放最后一根手指时,将生成igiPan/gfEnd事件。。。这两个事件都传递最后一个手指的位置信息。请注意,如果在相同的~0.1秒内释放两个手指,则没有问题。但正常使用表明这太快了。如果有办法增加这个周期,那么这也算是一个解决方案。你解决过这个问题吗?“我面临的正是这个问题。”PranoyC最后我换成了斯威夫特。不过,如果有人找到答案,我们会继续提问。