Reputation: 3125
I am using a UITextView and added UITextInputDelegate in my view controller. I have implemented textDidChange and dictationRecordingDidEnd methods. The textDidChange and dictationRecordingDidEnd are never called. Please help.
In MyViewController.h file
@interface MyViewController : UIViewController <UITextViewDelegate, UITextInputDelegate>
{
}
In MyViewController.m file
- (void) textDidChange:(id<UITextInput>)textInput
{
}
- (void)dictationRecordingDidEnd
{
}
- (void)dictationRecognitionFailed
{
textViewResults.text = @"Dictation Failed";
}
Upvotes: 3
Views: 2186
Reputation: 3084
Try overriding the dictationRecordingDidEnd method, instead, like this:
#import <UIKit/UIKit.h>
@interface MyTextField : UITextField
@end
#import "MyTextField.h"
@implementation MyTextField
- (void) dictationRecordingDidEnd {
printf("dictationRecordingDidEnd\n");
}
@end
I have not gone back and tested under earlier operating systems, but it works fine in iOS 8.1.1.
Upvotes: 1
Reputation: 26187
I had this same problem... seems that the methods don't get called like they should (and don't get called at all prior to 5.1). I did notice a notification that gets sent every time the input mode changes:
UITextInputCurrentInputModeDidChangeNotification
If you listen for that (in NSNotificationCenter) and then call:
[[UITextInputMode currentMode] performSelector:@selector(identifier)];
You'll get an NSString for the current input mode. Following that logic you can know that when it changes from @"dictate" to something else, then the dictation part has ended. (though the text change may not be processed yet, I haven't tried that all the way out).
Strangely, UITextInputMode is not private, but the objects returned by the methods don't have any public accessors... (thus the @selector(identifier) which gives you the string you neeed)... Don't think this will flag for Apple rejection but buyer beware.
Upvotes: 2
Reputation: 1215
I dont think you want to use the UITextInputDelegate protocol use the UITextInput one instead.
Upvotes: 2