Constraining the Redshift Distribution of Ultrahigh-Energy-Cosmic-Ray Sources by Isotropic Gamma-ray Background