Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Per https://groups.google.com/forum/#!topic/frank-discuss/6eZ2uXIuV9A, it appears that iOS 8
changed the way coordinate spaces work for UIScreen. That mean that tap coords for landscape orientation
wasn't being mapped properly. This fixes that issue by using UICoordinateSpace if available (iOS 8 and up).
  • Loading branch information
moredip committed Nov 16, 2014
1 parent c87422f commit 3482b71
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions PublicAutomation/UIAutomationBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,23 @@ + (CGPoint) tapPoint:(CGPoint)point {
}

+ (CGPoint) tapView:(UIView *)view atPoint:(CGPoint)point{
CGPoint tapPointInWindowCoords = [view convertPoint:point toView:[view window]];
CGPoint tapPointInScreenCoords = [[view window] convertPoint:tapPointInWindowCoords toWindow:nil];
CGPoint tapPoint = [self tapCoordsForView:view atPoint:point];

DLog(@"tapping at (%.2f,%.2f)", tapPointInScreenCoords.x,tapPointInScreenCoords.y);
[[self uia] sendTap:tapPointInScreenCoords];
DLog(@"tapping at screen coords (%.2f,%.2f)", tapPoint.x,tapPoint.y);
[[self uia] sendTap:tapPoint];

return tapPointInScreenCoords;
return tapPoint;
}

+ (CGPoint) tapCoordsForView:(UIView *)view atPoint:(CGPoint)point{
CGPoint tapPointInWindowCoords = [view convertPoint:point toView:[view window]];

// fix for https://github.com/moredip/Frank/issues/278
if( [UIWindow instancesRespondToSelector:@selector(convertPoint:toCoordinateSpace:)] ){
return [[view window] convertPoint:tapPointInWindowCoords toCoordinateSpace:[[UIScreen mainScreen] fixedCoordinateSpace]];
}else{
return [[view window] convertPoint:tapPointInWindowCoords toWindow:nil];
}
}

+ (CGPoint) downView:(UIView *)view {
Expand Down

0 comments on commit 3482b71

Please sign in to comment.