如何在 macOS 中单击按钮时更改显示方向
我想使用 Objective C 代码更改 macOS 中按钮单击事件的显示方向。
我想在我们从“系统偏好设置”打开显示时实现此功能,如果我们选择 90,则显示会旋转并且将以纵向模式显示。
图像显示“系统偏好设置”->显示设置:
我已尝试在按钮操作上执行以下代码,但它不起作用。我已经包含了#include
。
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
我该如何解决这个问题?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论