TiO2 has great potential for application in UV photodetectors due to its excellent photoelectric response. In this work, composite nanomaterials of TiO2 nanotube arrays (TiO2 NTAs) and polyaniline (PANI) were successfully prepared on titanium sheets using an anodic oxidation electrochemical method. The results showed that the TiO2 NTA/PANI composite materials had excellent UV photosensitivity and responsiveness and good stability and reproducibility. This was mainly attributed to the p–n heterostructure formed inside the TiO2 NTA/PANI composites that hindered the recombination of photogenerated electron–hole pairs and improved their utilization of UV light. This work provides a theoretical basis for the application of metal oxides in UV photodetectors, which is important for the development of UV photodetectors.