An electronic device (10, 401, 402, 404) comprising: a housing including a first edge, a second edge opposite the first edge, a third edge connected to a first end of the first edge and a first end of the second edge, a fourth edge connected to a second end of the first edge opposite to the first end of the first edge and a second end of the second edge opposite to the first end of the second edge, a hinge connected to the first edge and the second edge, a first housing structure corresponding to an area between the third edge and the hinge, and a second housing structure corresponding to an area between the fourth edge and the hinge, wherein each of the first edge and the second edge is foldable about the hinge, and wherein the first housing structure and the second housing structure face each other in a folded state of the first edge and the second edge; a foldable display including a first area extending from the hinge in a first direction and a second area extending from the hinge in a second direction opposite to the first direction; a first sensor disposed in the first housing structure and configured to detect spatial orientation of the first housing structure with respect to the direction of gravity; a second sensor (5 10s) disposed in the second housing structure and configured to detect spatial orientation of the second housing structure with respect to the direction of gravity; a memory configured to store a plurality of applications; and a processor configured to execute at least one of the plurality of applications, wherein the memory stores instructions that, when executed, cause the processor to: detect which of the first area and the second area includes a starting point, at which a user interface of the executed application starts to be output on the foldable display based on the foldable display being folded about the hinge by a predetermined angle (a), wherein the starting point is a location, obtain spatial orientation data related to an area in which the starting point is located, from one of the first sensor and the second sensor that corresponds to the area in which the starting point is located, and determine whether to rotate the user interface in the area in which the starting point is located, based on the spatial orientation data. a housing including a first edge, a second edge opposite the first edge, a third edge connected to a first end of the first edge and a first end of the second edge, a fourth edge connected to a second end of the first edge opposite to the first end of the first edge and a second end of the second edge opposite to the first end of the second edge, a hinge connected to the first edge and the second edge, a first housing structure corresponding to an area between the third edge and the hinge, and a second housing structure corresponding to an area between the fourth edge and the hinge, wherein each of the first edge and the second edge is foldable about the hinge, and wherein the first housing structure and the second housing structure face each other in a folded state of the first edge and the second edge; a foldable display including a first area extending from the hinge in a first direction and a second area extending from the hinge in a second direction opposite to the first direction; a first sensor disposed in the first housing structure and configured to detect spatial orientation of the first housing structure with respect to the direction of gravity; a second sensor (5 10s) disposed in the second housing structure and configured to detect spatial orientation of the second housing structure with respect to the direction of gravity; a memory configured to store a plurality of applications; and a processor configured to execute at least one of the plurality of applications, wherein the memory stores instructions that, when executed, cause the processor to: detect which of the first area and the second area includes a starting point, at which a user interface of the executed application starts to be output on the foldable display based on the foldable display being folded about the hinge by a predetermined angle (a), wherein the starting point is a location, obtain spatial orientation data related to an area in which the starting point is located, from one of the first sensor and the second sensor that corresponds to the area in which the starting point is located, and determine whether to rotate the user interface in the area in which the starting point is located, based on the spatial orientation data. detect which of the first area and the second area includes a starting point, at which a user interface of the executed application starts to be output on the foldable display based on the foldable display being folded about the hinge by a predetermined angle (a), wherein the starting point is a location, obtain spatial orientation data related to an area in which the starting point is located, from one of the first sensor and the second sensor that corresponds to the area in which the starting point is located, and determine whether to rotate the user interface in the area in which the starting point is located, based on the spatial orientation data.