The electron and hole g factors are the key quantities for the spin manipulations in semiconductor quantum nanostructures. However, for the individual nanostructures, the separate determination including the signs of those g factors is difficult by using some methods adopted conventionally in bulks and quantum wells. We report a convenient optical method for the sign identification of out-of-plane g factors in the individual quantum nanostructures, which utilizes the optically-induced nuclear spin switch. The method is demonstrated in typical single self-assembled In$_{0.75}$Al$_{0.25}$As/Al$_{0.3}$Ga$_{0.7}$As quantum dots and InAs/GaAs quantum rings, where the g factors with the opposite sign for electron and the same sign for hole are proved.