My daughter loved to pull my hair and this is what worked for us. Every time she pulled my hair, I would say, "Ouch that hurts mommy, we use nice hands." I would take her hand in mine and gently rub her hand through my hair. As I was doing this I would say, "See pretty, mommy has pretty hair, we use nice hands, etc. etc." She stopped the behavior in less than two weeks. She is 2.5 and still loves to rub her hands gently through my hair. This also works for hitting and biting. If you use it for biting, you say, "Our lips are for kissing and our mouths are for eating, we use nice mouths, etc. etc." Then plant a nice, gentle kiss on his cheek. If you just put your child down and walk away, this does not teach them the desirable behavior and they will only be confused as to why you no longer want to hold them.
When you do this, you are showing your child that hands, feet, etc. are used to do "nice" things to people. You are not focusing on the "bad" behavior, rather guiding them to the correct behavior. This really worked for my son when he was 10 months old and was hitting. Everyone "thought" he didn't understand what he was doing when he would hit. But he did. With this approach we didn't have to say, "NO!" and he learned how to deal with frustration, anger, etc. I hope this works for you. I would love to hear how it turns out and which approach works best for you.