If Tuesday’s hearing before a Senate panel led by Mr. Levin was meant to highlight Apple’s ability to avoid corporate taxes, it also illustrated the challenge in vilifying a company that tries to turn customers into fans.

Apple Chief Executive Tim Cook appears to have had some success on Capitol Hill. As he made his way through a packed hearing room, the CEO flashed a thumbs-up and made the peace sign to onlookers taking his picture—with iPhones. At another point, he chided one of the few reporters who was not typing on a MacBook.

On Monday, Sen. John McCain (R., Ariz.), the top Republican on the panel, described Apple as the “most egregious offender” among U.S. corporations engaging in tax strategies.

On Tuesday, Mr. McCain closed his questioning of Mr. Cook in a different tone, even if he used an expletive.

“What I really wanted to ask you is why the hell I have to keep updating apps on my iPhone,” the former presidential candidate said. “Why don’t you fix that?”

Mr. Cook responded, “Sir, we try to make them better all the time.”

Few things are worse in Washington these days than appearing “antibusiness.” So it would make sense if some lawmakers’ Apple flattery Tuesday was aimed at covering their political bases.

But they seemed to go out of their way to let Mr. Cook know that taxes or no taxes, they’re still buying his products.

During a break, the executive walked up to introduce himself to New Hampshire Republican Sen. Kelly Ayotte.