The only reason a priest would withold communion would be if he knew you were outside of communion with the church, you acted like you had no idea what you were doing when you went up for communion (making him think u weren’t ready to recieve) OR …you went up with your arms crossed over yourself like you were giving yourself a big hug…that’s a sign that you know you are unable to recieve communion and are instead asking for the priests blessing.
For yourself…to recieve communion :
1 You have to be a catholic in good standing
2 You must be in the state of grace…not knowingly in the state of mortal sin (a serious sin in which it pertains to serious matter, you fully knew what you were doing was wrong and had full control of your will when you did it).
3 Have observed the 1 hour fast prescribed by the church to prepare yourself to recieve the sacrament.