

If you’ve read this article:


You’ll know that on iOS7 devices (note: not on the simulator), there appears to be an issue related to how iOS7 considers the screen area, which means that coordinates are off by the height of the status bar at the top of the device. This also affects the coordinates given when a control is “clicked”, and can result in the wrong control being “clicked”, or a control not receiving a click at all.

The solution is to modify the TFMXViewBase.GetTouchCoord method in the unit FMX.Platform.iOS. Make a copy of the unit and put it somewhere in your library path, or just in the project directory, and make the following changes:

function TFMXViewBase.GetTouchCoord(const touches: NSSet; const Window: UIView; var x, y: single): Boolean;
  touch : UITouch;
  p     : CGPoint;
  // Add the following lines
  App: UIApplication;
  Device: UIDevice;
  Offset: Single;
  Result := False;
  if Assigned(touches) and (touches.count = 1) then
    // Add the following lines:
    Offset := 0;
    App := TUIApplication.wrap(TUIApplication.OCClass.SharedApplication);
    Device := TUIDevice.Wrap(TUIDevice.OCClass.currentDevice);
    if Pos('7', Device.systemVersion.UTF8String) = 1 then
      Offset := App.statusBarFrame.size.height;
    touch := TUITouch.Wrap(touches.anyObject);
    p := touch.locationInView(Window);
    x := p.x;
    // Comment out this line
    // y := p.y;
    // Add this line
    y := p.y - Offset;
    PlatformCocoa.FMouseCoord.X := X;
    PlatformCocoa.FMouseCoord.Y := Y;
    PlatformCocoa.FMouseCoord := Form.ClientToScreen(PlatformCocoa.FMouseCoord);
    Result := True;

Now you should find that the “clicks” are in the right place.