在自定义键盘扩展中,我们无法使用
`didRotateFromInterfaceOrientation:(UIInterfaceOrientation)fromInterfaceOrientation`
Run Code Online (Sandbox Code Playgroud)
和sharedApplication.
我需要在旋转时检测键盘上的纵向或横向.
如何在Custom Keyboard扩展中检测方向更改?
ios8 ios-app-extension uiinputviewcontroller custom-keyboard
我正在为iOS 8创建自定义键盘扩展.
我想获取用户在文本输入字段中编写的整个字符串.
不幸的是,我偶然发现了两个主要问题:
1)我在这个回调中得到null:
- (void)textDidChange:(id<UITextInput>)textInput
Run Code Online (Sandbox Code Playgroud)
2)当我调用这些方法时,我只得到部分字符串:
- [self.textDocumentProxy documentContextAfterInput];
- [self.textDocumentProxy documentContextBeforeInput];
Run Code Online (Sandbox Code Playgroud)
我想在用户正在编辑的文本输入中获取整个字符串,您建议我做什么?
谢谢!
我目前正在为iOS 8构建自定义键盘,虽然扩展名.当用户按下键盘视图上的某个按钮时,我想呈现一个全屏模态视图控制器.当我尝试呈现视图控制器时,它会尝试在键盘视图的边界内呈现.我正在使用[self presentViewController:animated:completion:]实例化的视图控制器.反正有没有提出全屏视图控制器?类似于照片编辑扩展(显示全屏视图控制器)
谢谢
keyboard uiviewcontroller ios uiinputviewcontroller ios8-extension
我有一个简单的UIInputViewController子类,只有两个重写的方法.我inputAccessoryViewController在我的UIViewController子类上使用此输入视图控制器,它成为第一响应者.我尝试通过添加约束来指定inputView的高度,如Apple文档所建议的那样.问题是我的约束不起作用,并且在添加约束时我得到autolayout异常
Unable to simultaneously satisfy constraints.
Probably at least one of the constraints in the following list is one you don't want.
...
(
"<NSLayoutConstraint:0x178aa1d0 V:[UIInputView:0x178a4ae0(0)]>",
"<NSLayoutConstraint:0x178b9520 V:[UIInputView:0x178a4ae0(500)]>"
)
Will attempt to recover by breaking constraint
<NSLayoutConstraint:0x178b9520 V:[UIInputView:0x178a4ae0(500)]>
Run Code Online (Sandbox Code Playgroud)
我认为这意味着系统已经为输入视图添加了零高度约束(因为它创建的高度为零).现在他们冲突和自动布局打破我的约束来解决问题.
当我尝试使用它作为inputViewController我的视图控制器(仅用于测试目的)时,我得到相同的异常,但不是零高度,它是216 px.它也打破了我的约束,高度保持默认.
- (void)viewDidLoad {
[super viewDidLoad];
// Do any additional setup after loading the view from its nib.
self.inputView.translatesAutoresizingMaskIntoConstraints = NO;
self.inputView.backgroundColor = [UIColor redColor];
}
- (void)updateViewConstraints {
CGFloat _expandedHeight = 500;
NSLayoutConstraint *_heightConstraint = …Run Code Online (Sandbox Code Playgroud) 我正在开发带键盘扩展的自定义键盘iOS8.
我可以用以下方法解雇键盘.
[self dismissKeyboard];
Run Code Online (Sandbox Code Playgroud)
但是上面的方法只是解雇键盘.我想这样做就像返回方法,可以喜欢GO或Search可以同时使用dismiss和Go事件,如iOS内置键盘.
我该怎么做?
请耐心等待,我在互联网上搜索了很多,但由于它是一个新的API,我找不到解决方案.
我正在尝试为iOS 8创建一个自定义键盘.除了在WebView中,它的工作方式非常好!它有前一个 - 下一个按钮,它在inputAccessoryView.我知道它是webview的只读属性,但由于iOS 8允许用户使用自定义键盘,我认为这个视图应该可以在某处编辑.有没有人遇到同样的问题?任何帮助,将不胜感激.
今天早上升级到8.3后,我在主题中收到错误.
下面的代码用于完美地工作,但它不再编译.你们有人可以帮助我吗?
protocol CustomAccessoryProtocol {
func controlButtonPressed(tag:Int)
}
class CustomAccessory : UIInputViewController {
var accessoryView : UIView!
var delegate : CustomAccessoryProtocol!
@IBOutlet weak var returnButton: UIButton!
@IBOutlet weak var backButton: UIButton!
@IBOutlet weak var forwardButton: UIButton!
init(delegate: CustomAccessoryProtocol){
super.init()
self.delegate = delegate
}
required init(coder aDecoder: NSCoder) {
super.init(coder: aDecoder)
fatalError("init(coder:) has not been implemented")
}
override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: NSBundle?) {
super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
let customNib = UINib(nibName: "CustomAccessory", bundle: nil)
accessoryView = customNib.instantiateWithOwner(self, options: nil)[0] …Run Code Online (Sandbox Code Playgroud) 我花了好几个小时试图弄清楚如何创建/然后让自定义inputView工作.我有一个网格TextInputs(思考拼字游戏板)按下时应该加载自定义inputView插入文本.
我创建了一个包含自定义的.xib文件.我能够创建一个并且具有显示但却永远无法获得实际更新它的值/文本.UI elementsinputViewCustomInputViewControllerinputViewTextInput
苹果文档似乎很清楚如何使这个工作,我已经看到的许多教程一直在使用Obj-C(由于现在似乎无法在swift中完成的小事情,我无法转换) .
为实现customInputView多个textInputs(委托链,控制器,.xib,视图等)而应该实现的总体架构和必要的代码片段是什么?
编辑 WKWebView 时是否有任何自定义 inputView 的方法?它没有像 UITextView 那样设置 inputView,但另一种方法可能是为整个应用程序加载自定义 inputViewController(自定义键盘)。我还没有找到强制在应用程序中的特定时间/地点使用 inputViewController 的方法。有没有办法做到这一点?
在我的应用程序中,我使用的是自定义键盘.不是那种需要用户安装键盘然后能够在任何地方使用它的应用程序扩展 - 只需在我的应用程序中.
为此,我创建了一个子类,UIInputViewController并在自定义nib文件中设置我的键盘.然后,在文本字段上我需要显示这个键盘,它调用的是inputView UIInputViewController.
这是调用键盘的代码:
let myKeyBoard = MyKeyboard()
scoreField.inputView = myKeyBoard.inputView!
scoreField.becomeFirstResponder()
Run Code Online (Sandbox Code Playgroud)
然后,在UIInputViewController中,调用此代码:
class MyKeyboard: UIInputViewController {
var myKeyBoardView: UIInputView!
override func viewDidLoad() {
super.viewDidLoad()
self.loadInterface()
}
func loadInterface() {
//load nib and set in view
let nib = UINib(nibName: "MyKeyboard", bundle: nil)
myKeyBoardView = nib.instantiateWithOwner(self, options: nil)[0] as! UIInputView
self.inputView = myKeyBoardView
view.backgroundColor = myKeyBoardView.backgroundColor
}
Run Code Online (Sandbox Code Playgroud)
这让您了解我的代码到目前为止的样子.我现在要做的是将此键盘的高度设置为自定义值,比如说200.我已经扫描了谷歌和SO,我找到的所有解决方案都只是iOS 8,或者表示不使用nib文件.我认为了解如何在iOS 9和带有笔尖的情况下获得一些知识会很有用.
如何使用nib更改iOS 9中自定义UIInputViewController的高度?
ios ×6
ios8 ×5
keyboard ×3
swift ×3
inputview ×2
autolayout ×1
cocoa-touch ×1
objective-c ×1
uitextinput ×1
uiwebview ×1
wkwebview ×1