An ultraviolet shielding hydrogel of P(NaSS-co-MPTC)/TiO2 was prepared by introducing TiO2 nanoparticles (TiO2 NPS) into polyampholyte matrix through photo-initiated radical copolymerization of cationic monomer of 3-(methacrylamide) propyltrimethylammonium chloride (MPTC) and anionic monomer of sodium 4-vinylbenzenesulfonate (NaSS) in the aqueous solution of sodium chloride (NaCl). FTIR, XPS, TEM, XRD, and SEM were used to characterize the morphology and structure of hydrogel of P(NaSS-co-MPTC)/TiO2. The result showed that anatase TiO2 NPS with the size about 15 ~ 20 nm were not just acted as ultraviolet shielding agent and general photo-initiator, they also could be crosslinked in polyampholyte matrix by hydrogen bonding between hydroxyl groups on the surface of TiO2 NPS and sulfonate groups on the polymer chains. Based on two kinds of reversible weak bonds of hydrogen bond and ionic bond, the P(NaSS-co-MPTC)/TiO2 hydrogel exhibited excellent mechanical properties and self-healing ability at ambient conditions, which will greatly increase its service life being a UV inhibitor.