The present disclosure provides a method for detecting a position of a movable structure (20). The movable structure (20) is applicable to an electronic device (100) including a body (10) and a detection component (30), and configured to move between a first position and a second position. The detection component (30) includes at least one distance sensor (32, 34) disposed on the movable structure (20). The at least one distance sensor (32, 34) is configured to be received in the body (10) when the movable structure (20) is at the first position and to protrude beyond the body (10) when the movable structure (20) is at the second position. The method includes: receiving a detection signal value outputted by the at least one distance sensor (32, 34); and determining a position of the movable structure (20) relative to the body (10) according to the detection signal value. |