Politically, McCain is despicable. There's plenty of fodder for any conservative critic to use against McCain based on his voting record in the Senate and the type of legislation he loudly championed. Instead of going after this, Trump decided to go the cheap ad hominem route. Typical.
Trump acted reflexively, it seems, but his refusal to apologize and to double down on McCain's own failures in protecting veterans was IMHO politically the right move for him. His statement that those who served and did not get captured don't receive the attention that McCain gets is also a very valid observation. For me, anyone who puts the uniform on and puts their life on the line in any capacity is a hero.