My little boar, who, I think, had been a bit spoiled used to jump up at me when I came in with food. I stopped him by offering him a banana and if he jumped up, putting it behind my back at the same time as saying "Sit!! firmly whilst holding the banana-less hand above his snout. He got the banana when he backed away a bit. It took only a day or so for him to learn and now, bless him, he sits as soon as he sees me
Obviously, if your pigs are for slaughter this would not be a good idea (even I couldn't eat a pig that sat and offered a trotter
) but maybe something along these lines. Just getting them to back off would do.