You can simply make a check of the screen resolution to see which is a bigger number
if ViewportRight(0) > ViewportBottom(0), then you are playing in landscape
if its the opposite you are playing in portrait.
Then simply position your UI accordingly depending on which mode you are in.
If you are holding your phone in portrait, then ViewportRight(0) will be smaller than ViewportBottom(0)