工作围绕听写/自定义文本视图错误 [英] work around for dictation / custom text view bug

查看:171
本文介绍了工作围绕听写/自定义文本视图错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个视图,实现 UIKeyInput 并覆盖 shouldBecomeFirstResponder 返回 code>。轻触此视图时,键盘弹出。如果用户点击听写按钮,按下完成,然后尝试关闭键盘,应用程序崩溃与:

I have a view that implements UIKeyInput and overrides shouldBecomeFirstResponder to return YES. When this view is tapped, the keyboard pops up. If the user taps the dictation button, pushes done, and then tries to dismiss the keyboard, the app crashes with:

Fatal Exception: NSInternalInconsistencyException NSInternalInconsistencyException
We were never set up properly to stream in this document.



我想知道是否有人知道一个工作来解决这个bug?我尝试实现 UITextInput ,并留下相关的方法空白,这实际上是工作。然而, UITextInput 正在访问我的insertText方法,当用户尝试使用Dictation和放入垃圾。我还没有准备好实现听写,所以我实际上只是想禁用它,现在有一些工作。任何输入都会感谢!

I was wondering if anyone knows a work around to fix this bug? I tried implementing UITextInput and leaving dictation related methods blank and this actually works. However, UITextInput is accessing my insertText method when the user tries to use Dictation and putting in junk. I'm not yet ready to implement dictation, so I'd actually just like to disable it for now with some sort of work around. Any input would be appreciated!

推荐答案

实际上,实现 UITextInput 问题。当用户做一个成功的听写,它只会发送一个空格给你的insertText方法(不完全确定如何让听写在自定义文本视图中正确工作,现在我只是想修复这个错误)。下面列出了您需要用于 UITextInput 的所有方法和属性,以节省您一些时间:

Actually, implementing UITextInput fixes the problem. When the user does a successful dictation, it will just send a space to your insertText method (not exactly sure how to get dictation to work correctly in a custom text view, right now I'm just wanting to fix this bug). Below I've listed all the methods and properties you have to use for UITextInput to save you some time:

属性::

Properties:

@property(nonatomic, readonly) UITextPosition *beginningOfDocument;
@property(nonatomic, readonly) UITextPosition *endOfDocument;
@property(nonatomic, assign) id<UITextInputDelegate> inputDelegate;
@property(nonatomic, readonly) UITextRange *markedTextRange;
@property(nonatomic, copy) NSDictionary *markedTextStyle;
@property(readwrite, copy) UITextRange *selectedTextRange;
@property(nonatomic, readonly) id<UITextInputTokenizer> tokenizer;

方法

- (UITextWritingDirection)baseWritingDirectionForPosition:(UITextPosition *)position inDirection:(UITextStorageDirection)direction
{
    return nil;
}

- (CGRect)caretRectForPosition:(UITextPosition *)position
{
    return CGRectZero;
}

- (void)unmarkText
{

}

- (UITextRange *)characterRangeAtPoint:(CGPoint)point
{
    return nil;
}
- (UITextRange *)characterRangeByExtendingPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction
{
    return nil;
}
- (UITextPosition *)closestPositionToPoint:(CGPoint)point
{
    return nil;
}
- (UITextPosition *)closestPositionToPoint:(CGPoint)point withinRange:(UITextRange *)range
{
    return nil;
}
- (NSComparisonResult)comparePosition:(UITextPosition *)position toPosition:(UITextPosition *)other
{
    return nil;
}
- (void)dictationRecognitionFailed
{
}
- (void)dictationRecordingDidEnd
{
}
- (CGRect)firstRectForRange:(UITextRange *)range
{
    return CGRectZero;
}

- (CGRect)frameForDictationResultPlaceholder:(id)placeholder
{
    return CGRectZero;
}
- (void)insertDictationResult:(NSArray *)dictationResult
{
}
- (id)insertDictationResultPlaceholder
{
    return nil;
}

- (NSInteger)offsetFromPosition:(UITextPosition *)fromPosition toPosition:(UITextPosition *)toPosition
{
    return nil;
}
- (UITextPosition *)positionFromPosition:(UITextPosition *)position inDirection:(UITextLayoutDirection)direction offset:(NSInteger)offset
{
    return nil;
}
- (UITextPosition *)positionFromPosition:(UITextPosition *)position offset:(NSInteger)offset
{
    return nil;
}

- (UITextPosition *)positionWithinRange:(UITextRange *)range farthestInDirection:(UITextLayoutDirection)direction
{
    return nil;
}
- (void)removeDictationResultPlaceholder:(id)placeholder willInsertResult:(BOOL)willInsertResult
{
}
- (void)replaceRange:(UITextRange *)range withText:(NSString *)text
{
}
- (NSArray *)selectionRectsForRange:(UITextRange *)range
{
    return nil;
}
- (void)setBaseWritingDirection:(UITextWritingDirection)writingDirection forRange:(UITextRange *)range
{
}
- (void)setMarkedText:(NSString *)markedText selectedRange:(NSRange)selectedRange
{
}

- (NSString *)textInRange:(UITextRange *)range
{
    return nil;
}
- (UITextRange *)textRangeFromPosition:(UITextPosition *)fromPosition toPosition:(UITextPosition *)toPosition
{
    return nil;
}

这篇关于工作围绕听写/自定义文本视图错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆