my husband hates me

I have been with my husband for 8 years, married for 3 and we have a beautiful 16 month old daughter. He is an amazing dad, works hard, and helps me out around the house. I couldn't ask for more, right? Well our problems started when I got pregnant. He talked about wanting to start a family but then he slowly withdrew.. I had a lot of complications during my pregnancy and was very sick and had to be put on bed rest at 6 1/2 months. so this caused major stress. He began going out with his friends more and more and leaving me by myself, he began drinking more. it got a little better when the baby was born, he is head over heels for her. Then it got worse. he doesn't show any affection. He pretty much ignores me unless he is angry at me for something (usually petty). I have tried to talk to him about why he acts this way and he says he is fine. he doesn't want to talk at all. well then I began talking to an ex of mine from years ago. I know it was wrong however I know I did this because I feel so alone. I feel as if I have a roommate rather than a husband. well he found out about the texting and I blocked the man's number and completely stopped talking to him. i feel that things are only getting worse... and i have no idea what to do