Self-powered ultraviolet (UV) photodetectors (PDs) based on a ZnO/NiO heterojunction have garnered increasing interest due to their straightforward preparation process, exceptional photoresponse performance, and independence from external power sources. However, PDs' detection capabilities are hindered by a high concentration of defects and low carrier mobility within a heterojunction. In this study, the integration of ZnO nanowire (NW) arrays featuring light-trapping structures is explored with heterostructured thin films to optimize the optical functional layer's structure. The resulting ZnO NWs/ZnO/NiO heterojunction PDs, fabricated via RF magnetron sputtering and hydrothermal methods, exhibit significant optoelectronic behavior when exposed to light, functioning autonomously without the need for an external power supply. The synergistic effect of the heterojunction and the light-trapping structure significantly enhances the PD's overall performance. The optimized heterojunction PD demonstrates superior responsivity, detectivity, lower noise equivalent power, and enhanced external quantum efficiency. This work supports the broader application of the light-trapping effect of NWs in a heterostructure and offers novel insights into the development of practical, miniaturized self-powered UV PDs.