It wasn’t only Obama, but also McCain that helped elect Trump, both by the contrast of being himself an ineffectual deep state Rhino, but by nominating a firebrand like Palin to energize the GOP base. That’s the real reason the McCain’s didn’t want her out the funeral - so as not to be reminded that they started the Trump train in motion with her nomination.
A week later when asked about McCain's comments, Trump gave his now famous comment: "He's not a war hero. He's a war hero because he was captured. I like people who weren't captured."
When you attack Trump's supporters, you're attacking him...and as a man who is very loyal to his supporters, he responded correctly.