ILI9488 with XPT2046 using esp32 example code not working in potrait mode

I am using ili9488 3.5 inch 480 X 320 dipsplay with xpt2046 touch on esp32. The lvgl example code is working perfectly in landscape mode but in portrait mode touch is not working properly if i pressed at one location then it is being reflected at some other location on the touch screen. Please help me. I am able get co-ordinates both in landscape and portrait.