Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我在下面找到了获取键盘布局但无法将其转换为字符串的代码:
TISInputSourceRef sourceRef = TISCopyCurrentKeyboardLayoutInputSource();
如果您使用CFShow(sourceRef);,您可以看到键盘布局,但无法转换 sourceRef。
CFShow(sourceRef);
如何在字符串中获取键盘布局???
我使用这个 objc 代码:
#import <Carbon/Carbon.h> TISInputSourceRef source = TISCopyCurrentKeyboardInputSource(); NSString *s = (__bridge NSString *)(TISGetInputSourceProperty(source, kTISPropertyInputSourceID));
您也可以将其转换CFStringRef为 objc 字符串。
CFStringRef