Despite the rapid development of molecular rotors over the past decade, it still remains a huge challenge to understand their confined behavior in ultrathin two-dimensional (2D) nanomaterials for molecular recognition. Here, we report an all-carbon, 2D π-conjugated aromatic polymer, named NUS-25, containing flexible tetraphenylethylene (TPE) units as aggregation-induced emission (AIE) molecular rotors. NUS-25 bulk powder can be easily exfoliated into micrometer-sized lamellar freestanding nanosheets with a thickness of 2-5 nm. The dynamic behavior of the TPE rotors is partially restricted through noncovalent interactions in the ultrathin 2D nanosheets, which is proved by comparative experimental studies including AIE characteristics, size-selective molecular recognition, and theoretical calculations of rotary energy barrier. Because of the partially restricted TPE rotors, NUS-25 nanosheets are highly fluorescent. This property allows NUS-25 nanosheets to be used as a chemical sensor for the specific detection of acenaphthylene among a series of polycyclic aromatic hydrocarbons (PAHs) via fluorescent quenching mechanism. Further investigations show that NUS-25 nanosheets have much higher sensitivity and selectivity than their stacked bulk powder and other similar polymers containing dynamic TPE rotors. The highly efficient molecular recognition can be attributed to the photoinduced electron transfer (PET) from NUS-25 nanosheets to acenaphthylene, which is investigated by time-resolved photoluminescence measurements (TRPL), excitation and emission spectra, and density functional theory (DFT) calculations. Our findings demonstrate that confinement of AIE molecular rotors in 2D nanomaterials can enhance the molecular recognition. We anticipate that the material design strategy demonstrated in this study will inspire the development of other ultrathin 2D nanomaterials equipped with smart molecular machines for various applications.