Technically any move can if you lock onto the opponent the turn before (by using certain moves), or you have the ability No Guard:
>...most moves will miss regardless of accuracy, even moves that never miss. If a Pokémon has been taken aim at, the aimed Pokémon can still hit Pokémon during their semi-invulnerable turn. A Pokémon with No Guard can hit the Pokémon during their semi-invulnerable state, and a Pokémon with No Guard in the semi-invulnerable state can be hit by any Pokémon.
But otherwise, there are moves that will hit Pokemon in the "semi-invulnerable" condition that Fly puts you in:
>Pokémon that use Fly, Bounce or Sky Drop, or are targeted by Sky Drop fly or are flown up high, and are vulnerable to Gust, Smack Down, Sky Uppercut, Thunder, Twister, and Hurricane.
Interestingly, Rock Slide is not one of them. Perhaps there was an in-battle condition that caused it to work? Do you have a replay?