Self-powered ultraviolet photodetectors with bipolar photoresponse have great potential in the fields of ultraviolet optical communication, all-optical controlled artificial synapses, high-resolution ultraviolet imaging equipment, and multiband photoelectric detection. However, the current low optoelectronic performance limits the development of such polar switching devices. Here, we construct a self-powered ultraviolet photodetector based on GaN and In/Sn-doped Ga2O3 (IGTO) nanowires (NWs) pn junction structure. This unique nanowire/thin film structure allows GaN and IGTO to dominate the absorption of light at different wavelengths, resulting in a highly bipolar photoresponse. The device has a responsivity of 2.04 A/W and a normalized detectivity of 7.18 × 1013 Jones at 254 nm and a responsivity of -2.09 A/W and a normalized detectivity of -7 × 1013 Jones at 365 nm, both at zero bias. In addition, it has an extremely high Ilight/Idark ratio of 1.05 × 105 and ultrafast response times of 2.4/1.9 ms (at 254 nm) and 5.7/5.2 ms (at 365 nm). These excellent properties are attributed to the high specific surface area of the one-dimensional nanowire structure and the abundant voids generated by the nanowire network to enhance the absorption of light, and the p-n junction structure enables the rapid separation and transfer of photogenerated electron-hole pairs. Our findings provide a feasible strategy for high-performance wavelength-controlled polarity switching devices.