It develops yieldedness while also getting his attention. Once you know how to get the horse's attention, you can use this technique to keep his attention off things like gates. As you approach the gate, begin getting his attention on the opposite side. You may think that moving a rein or a leg will signal him to turn, but the rest of your body is telling him to keep going straight and is not allowing him to turn. Another common distraction is grass.
Many horses take a swipe at it every chance they get.
Again, the attention is not on you enough. Get in the habit of keeping the horse's attention off distractions and on the rider. One reason the horse's attention drifts is that he is not being given enough interesting things to think about. See if you can get him to take longer strides without speeding up. Don't let him get so bored that he looks at grass.