Ah, my bad, I was just thinking about the iPad. There are some Apple Support discussions relative to phones with picture orientation issues. You might consider a search there to see what, if anything, applies to you. Folks are talking about compass calibration and turning settings on and off. This was when iOS 8 and iPhone 6 came out, so maybe things have been fixed in an update, too. I'm not that great an Apple user and haven't experienced it on the phone, so I'm afraid I can't comment on the support discussions.
We had the experience described with the iPad a couple of years ago on one particular website, and discovered as long as we put the button on the appropriate side (which I've now forgotten but think it was right), it solved our problem. The iPad is my wife's, and I only used it some while on a vacation.