我正在编写自定义键盘.当我在设置中添加键盘时,我看到了这样的.它显示英语.
是否可以将"英语"改为其他?是在plist?或者我可以在哪里更改?

我做了一个自定义键盘.当您长按一个键时,会PopupWindow在键上方显示一些额外的选项.问题是在API 28中,此弹出窗口被剪裁(甚至完全隐藏在顶行).
popupWindow.setClippingEnabled(false);
Run Code Online (Sandbox Code Playgroud)
但是,对于API 28,问题又回来了.这是更多的代码:
private void layoutAndShowPopupWindow(Key key, int xPosition) {
popupWindow = new PopupWindow(popupView,
LinearLayout.LayoutParams.WRAP_CONTENT,
LinearLayout.LayoutParams.WRAP_CONTENT);
popupWindow.setClippingEnabled(false);
int location[] = new int[2];
key.getLocationInWindow(location);
int measureSpec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED);
popupView.measure(measureSpec, measureSpec);
int popupWidth = popupView.getMeasuredWidth();
int spaceAboveKey = key.getHeight() / 4;
int x = xPosition - popupWidth / popupView.getChildCount() / 2;
int screenWidth = getScreenWidth();
if (x < 0) {
x = 0;
} else if (x + popupWidth > screenWidth) {
x = …Run Code Online (Sandbox Code Playgroud) 当我尝试构建并运行我的键盘扩展时,它有时只会崩溃Thread 1: signal SIGQUIT.
我无法重现错误.有时我可以构建和运行我的应用程序,但大多数时候键盘才会退出.这发生在实际设备上.在模拟器中,它没有打开键盘说Waiting to Attach.
控制台一开始不输出任何错误.但是,如果我在Debug导航器中将下拉列表更改为View UI Hierachy,我会得到以下描述:
Details: No plist data for fetching view hierarchy: error evaluating expression “(id)[(Class)objc_getClass("DBGViewDebuggerSupport_iOS") fetchViewHierarchyWithOptions:(id)[(Class)objc_getClass("NSDictionary") dictionaryWithObjects:(id)[(id)[(id)[(Class)objc_getClass("NSArray") arrayWithObject:(id)[(Class)objc_getClass("NSNumber") numberWithBool:1]] arrayByAddingObject:(id)[(id)[(Class)objc_getClass("NSArray") arrayWithObject:@"_UIVisualEffectBackdropView"] arrayByAddingObject:@"_UIBackdropEffectView"]] arrayByAddingObject:(id)[(Class)objc_getClass("NSNumber") numberWithBool:0]] forKeys:(id)[(id)[(id)[(Class)objc_getClass("NSArray") arrayWithObject:@"DBGViewDebuggerUseLayersAsSnapshots"] arrayByAddingObject:@"DBGViewDebuggerEffectViewsToSnapshotAsImage"] arrayByAddingObject:@"DBGViewDebuggerAlwaysEncodeLayers"]]]”: error: Execution was interrupted, reason: EXC_BREAKPOINT (code=1, subcode=0x18daddc34).
The process has been returned to the state before expression evaluation.
Method: -[DBGAbstractViewDescriber handleFetchedViewInfo:fetchError:resultHandler:]
Please file a bug at http://bugreport.apple.com with this warning message and any useful information you can provide.
Run Code Online (Sandbox Code Playgroud)
我还截取了流程的截图.
我做错了什么,怎么能阻止我的键盘扩展在运行时一直退出?它实际上是一个如描述中所述的错误吗?
我正在尝试使用我作为按钮放入的图像为iOS构建自定义键盘.当我按下按钮时,链接到该按钮的图像被放入一个属性字符串,该字符串被加载到自定义键盘视图内的UiTextView中.那很有效.
问题是,当我将新图像附加到属性字符串时,字符串中的旧图像和新图像都将更改为我当前按下的图像.我无法理解为什么字符串中的旧图像正在发生变化.
有什么建议?我已经尝试使用replaceCharactersInRange和insertAttributedString但无法使其工作.这是代码(在viewDidLoad之后):
let textAttachment = NSTextAttachment()
let textView = UITextView(frame: CGRectMake(5, 5, 200, 40))
var attributedString = NSMutableAttributedString(string: "")
@IBAction func buttonPressed(button :UIButton) {
let string = button.titleLabel?.text
textAttachment.image = UIImage(named: "\(string!).png")!
textAttachment.image = UIImage(CGImage: textAttachment.image!.CGImage!, scale: 6, orientation: .Up)
let attrStringWithImage = NSAttributedString(attachment: textAttachment)
attributedString.appendAttributedString(attrStringWithImage);
textView.attributedText = attributedString;
}
Run Code Online (Sandbox Code Playgroud)
谢谢!
我们想开发具有一些独特功能(例如在键盘上翻译)的移动键盘应用程序(第三方键盘)。
我们想知道是否有一种方法可以同时为 IOS 和 Android 开发它,使用 Flutter 或任何其他解决方案?
我正在创建一个iOS 8自定义键盘扩展,我正在寻找一种方法来确定用户何时切换到另一个输入,以便更改我的布局.
例如,当用户选择UITextField带有类型的UIKeyboardTypeEmailAddressI时,我打算提供自定义键盘,当用户选择UITextField带有类型的另一个时UIKeyboardTypeDecimalPad,我想要注意它,并更新键盘的布局.当键盘类型更改以更新键盘布局时,如何通知?
我正在使用此解决方案(/sf/answers/1805084991/)来检测在Settins应用程序(iOS 8)中激活的所有自定义键盘:
- (void)printoutAllActiveKeyboards {
// Array of all active keyboards
NSArray *keyboards = [[[NSUserDefaults standardUserDefaults] dictionaryRepresentation] objectForKey:@"AppleKeyboards"];
for (NSString *keyboard in keyboards)
NSLog(@"Custom keyboard: %@", keyboard);
}
Run Code Online (Sandbox Code Playgroud)
但这对我的项目来说还不够 - 我需要知道用户当前选择哪个自定义键盘进行文本输入.我有研究stackoverflow和其他资源,但没有找到任何解决方案.有没有办法在我的应用程序中检测当前选择的文本输入中的哪个自定义键盘?
谢谢!
我在自定义键盘上添加了textfield(keyboardTextField)和UISwitch.我可以在Switch value my code的基础上为(keyboardTextField)设置焦点ON或OFF.
- (void)switchToggled:(id)sender
{
UISwitch *mySwitch = (UISwitch *)sender;
if ([mySwitch isOn])
{
[keyboardTextField becomeFirstResponder];
}
else
{
[keyboardTextField resignFirstResponder];
}
}
Run Code Online (Sandbox Code Playgroud)
因此,当我的自定义键盘在我的设备的每个应用程序中启动它时,第一次发生了什么事情,但是在将Switch值更改为On然后OFF并且现在我的自定义后,我无法选择主应用程序的输入视图.键盘无法在我的设备的任何应用程序中写任何东西.
keyboard-events becomefirstresponder ios8 custom-keyboard ios-keyboard-extension
是否可以识别语音,然后使用自定义键盘将其转换为文本。就像 iPhone 中的默认消息应用程序一样。
截屏
1. iphone 键盘默认识别语音。

2. 语音转文字

任何帮助将不胜感激。
提前致谢。
speech-recognition voice-recognition ios swift custom-keyboard
UIViewController的InterfaceOrientation已弃用且Document建议使用[[UIApplication sharedApplication] statusBarOrientation],但iOS 8的扩展中没有sharedApplication.
正如@Retro所提到的,在大多数情况下,您可以使用self.traitCollection.verticalSizeClass或self.traitCollection.horizontalSizeClass在UIViewController中获取方向信息.