如果您的意思是获取显示屏分辨率。
这可能就是您所追求的。
NSScreen* thescreen;
id theScreens = [NSScreen screens];
for (thescreen in theScreens) {
NSLog(@"%@x%@", [NSNumber numberWithFloat:[thescreen frame].size.width], [NSNumber numberWithFloat:[thescreen frame].size.height]);
}
这个例子将为您提供set所有显示器的分辨率
看看苹果NSScreen https://developer.apple.com/library/mac/documentation/Cocoa/Reference/ApplicationKit/Classes/NSScreen_Class/Reference/Reference.html
如果这不完全是您所追求的,您可以扩展您的问题吗?
Cheers
-
UPDATE。关于OP关于想要所有可能的显示分辨率的评论。
这可能是您所追求的,您将不得不使用它来查看它是否确实返回了正确的信息。我得到了多个结果,因此过滤器。但如果你玩它,你应该能够把它变薄。
测试项目使用 ARC,它强制使用 __bridges..
但我再次相信您将有时间更好地编码。
我的参考是石英显示服务参考 https://developer.apple.com/library/mac/documentation/GraphicsImaging/Reference/Quartz_Services_Ref/Reference/reference.html
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);
-->
display deatails = (
2560x1440,
1280x720,
640x480,
800x600,
1024x768,
1280x1024,
1344x756,
1600x900,
1680x1050,
1920x1080,
1600x1200,
1920x1200
)