In this paper, we consider a cellular Internet of UAVs with a massive number of UAVs, where the sensory data can be transmitted to the mobile devices by UAV-toDevice (U2D) communications, or to the base station (BS) by UAV-to-Network (U2N) communications. To improve the spectral efficiency, the U2D links can share the spectrum with U2N links. Since the sensing and transmission of the UAV are coupled by the trajectory, it is necessary to optimize the trajectory. Due to the underlay property, the trajectories of UAVs will have an impact on each other, which makes the trajectory optimization more challenging when the number of UAVs is large. To tackle this challenge, mean-field approximation is an efficient method to approximate the interactions among UAVs. Since the UAVs in the cellular Internet of UAVs are distinguishable, we propose a mean-field-type (MFT) control method to solve the trajectory optimization problem, where the interactions among. The simulation results verify the effectiveness of our proposed method.