Hin*_*chy 3 c++ macos resolutions objective-c
我正在制作游戏,我想获取启动器的有效全屏分辨率列表。我找不到为 Mac OS X 执行此操作的任何方法;
就像在系统首选项 Displays窗格中一样。

是否可以?
如果您的意思是获取显示屏幕分辨率。
这可能就是你所追求的。
NSScreen* thescreen;
id theScreens = [NSScreen screens];
for (thescreen in theScreens) {
NSLog(@"%@x%@", [NSNumber numberWithFloat:[thescreen frame].size.width], [NSNumber numberWithFloat:[thescreen frame].size.height]);
}
Run Code Online (Sandbox Code Playgroud)
此示例将为您提供所有显示器的设置分辨率
看看苹果NSScreen
如果这不是您所追求的,您可以扩展您的问题。
干杯
这可能是您所追求的,您将不得不使用它来查看它是否确实返回了正确的信息。我得到了多个结果,因此过滤器。但是如果你玩它,你应该能够把它减薄。
测试项目使用的是 ARC,它强制使用 __bridges .. 但我再次相信你会有时间把它编码得更好。
我的参考资料是 Quartz Display Services Reference
NSArray* theref = (__bridge NSArray *)(CGDisplayCopyAllDisplayModes ( CGMainDisplayID(), nil ));
NSMutableArray * rezes = [[NSMutableArray alloc]init];
for (id aMode in theref) {
CGDisplayModeRef thisMode = (__bridge CGDisplayModeRef)(aMode);
size_t theWidth = CGDisplayModeGetWidth( thisMode );
size_t theHeight = CGDisplayModeGetHeight( thisMode );
NSString *theRez = [NSString stringWithFormat:@"%zux%zu",theWidth,theHeight];
if (![rezes containsObject:theRez]) {
[rezes addObject:theRez];
}
}
NSLog(@" display deatails = %@", rezes);
Run Code Online (Sandbox Code Playgroud)
-->
display deatails = (
2560x1440,
1280x720,
640x480,
800x600,
1024x768,
1280x1024,
1344x756,
1600x900,
1680x1050,
1920x1080,
1600x1200,
1920x1200
)
| 归档时间: |
|
| 查看次数: |
1012 次 |
| 最近记录: |