'How to change display orientation in mac OS on button click
I want to change the display orientation on button click event in mac OS using objective c code.
I want to implement this functionality when we open display from "System Preference" and if we select 90 then the display rotation happens and it will be displayed in portrait mode.
Image is displaying "System Preference" -> display settings:
I have tried following code on button action but it is not working. I have included #include <IOKit/graphics/IOGraphicsLib.h>.
io_service_t service = CGDisplayIOServicePort(eDisplay); //IOKit Handle (get myDisplayID yourself)
IOOptionBits options = (0x00000400 | (kIOScaleRotate90) << 16); //Some undocumented hex'ing
IOServiceRequestProbe(service, options); //Set rotation to display
How can I resolve this issue?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|

