The design and construct pn heterojunction to reduce the recombination rate of photogenerated electron-hole pairs can effectively improve photocatalytic activity. In this study, ZnO/NiO heterojunctions were fabricated by annealing a Zn/Ni metal organic framework precursor synthesized via coprecipitation. The effects of the precursor annealing temperature on the microstructure, morphology, and optical properties of the ZnO/NiO nanocomposites were investigated using X-ray diffraction, scanning electron microscopy, transmission electron microscopy, X-ray photoelectron spectroscopy, and UV-vis absorption spectroscopy. The results showed that the nanocomposite was composed of hexagonal wurtzite ZnO and cubic NiO, with the former being the dominant phase. Large ZnO nanoparticles were attached to small NiO nanoparticles, and a pn heterojunction interface was formed. The photodegradation performance of the nanomaterials was evaluated by monitoring the degradation of RhB under irradiation by ultraviolet light. The ZnO/NiO nanocomposites exhibited excellent photocatalytic activity when the annealing temperature was 550 °C. The photodegradation mechanism was also analyzed in detail, revealing that the heterojunction between the n-type ZnO and the p-type NiO played an important role in impeding the recombination of photogenerated electron-hole pairs and improving the photocatalytic efficiency.