All kinds of mainstream IM, have their own definition of the keyboard: Emoji keyboard, select the picture of the keyboard. is actually a inputview.
First, we want to make sure that our keyboard is called by the input box. That is, we can set the inputview of a certain textview.
// Let the keyboard enter the edit state, replace the input source with the custom FV // FV is a custom UIView-(void) Callfacekeyboard: (UIButton *) button { [Ktextview Becomefirstresponder]; = FV; [Ktextview reloadinputviews]; [Ktextview.inputview Becomefirstresponder]; // set the custom keyboard to the first response }
Now this keyboard is paged out. Let's see how the keyboard is implemented.
1 . h2 #import<UIKit/UIKit.h>3 4 @interfaceFacekeyboardview:uiview5 //which expression was clicked ?6@property (nonatomic,copy)void(^Tapactionblock) (Nsinteger FaceID);7 //Send Message8@property (nonatomic,copy)void(^Sendemojiblock) ();9 Ten-(Instancetype) initWithFrame: (CGRect) frame Facearray: (Nsarray *) Facesarray; One @end A - - the . M - - #import "FaceKeyboardView.h" - @implementationfacekeyboardview{ +Nsmutablearray * DataArray;//an array of resources for emoticons -Uiscrollview * ScrollView;//The main selection page +UIButton * Sendbutton;//send button A } at //this must be implemented and set to Yes --(BOOL) Canbecomefirstresponder { - returnYES; - } --(Instancetype) initWithFrame: (CGRect) frame Facearray: (Nsarray *) facesarray{ -Self =[Super Initwithframe:frame]; in if(self) { - //Set Send button to code ... + //Set Body content - [self setscrollviewcontent:facesarray]; the } * returnSelf ; $ }Panax Notoginseng -- (void) Setscrollviewcontent: (Nsarray *) Array { the //Here's a view of each expression. Add a Click event + } A the- (void) Touchthisview: (Uigesturerecognizer *) Tap { + if([Tap.view Iskindofclass:[uiimageviewclass]]) - if(self.) Tapactionblock) { $ Self . Tapactionblock (Tap.view.tag); $ } - } - the- (void) Send: (UIButton *) button { - if(self.) Sendemojiblock) {Wuyi Self . Sendemojiblock (); the } - } Wu - @end About
Here, as long as the implementation of the block, the corresponding things to add to the TextView inside the good.
Of course, to turn it off, set TextView's Inputview to nil.
IOS IM Development Recommendations (iii) Add a custom keyboard