Localization transition for a polymer near an interface