The president’s appearance at the dinner came after months of warring with the press