iOS Development-No. 05-Projects-10-tweet

Source: Internet
Author: User

1. Click on the expression


1.1 Expression Magnification interface




1.2 Realization Ideas


1> Monitor Emoji button click

2> can only display one magnifying glass at a time, create one, do not create it repeatedly

3> Magnifier should be as a whole hwemotionpopview, and relatively simple, with xib to achieve, provide class method

4> lazy Loading in Hwemotionpageview Hwemotionpopview

Note 1 : Hwemotionpopview Add location issues, if added to the Hwemotionpageview Above , it will be blocked by the tool table above, therefore, should be added to the topmost window UIWindow , and not Keywindow because the keyboard that pops up is also a UIWindow , covered in Keywindow above, Keywindow is behind the main controller!!!

Note 2 : As added to UIWindow , the coordinate system changes, and the coordinate system transformation should be noticed .




5> set Hwemotionpopview inside the button expression, you need to click the button, take out the corresponding emotion model, set to Hwemotionpopview

Method One: For each expression button binding tag, according to tag out self.emotions array of emotion model;

Method Two:

1. a button corresponding to an expression model, you should customize the button, give each button an expression model, can be directly based on the button to remove the expression model, and rewrite the button in the expression model Setter method, will PNG or is Code Set button display encapsulated inside

2. set the hwemotionpopview inside the button expression can only be passed to one of its expression model,XIB The buttons on the inside correspond to the custom emoticons button






Hwemotionpageview expression button click




2. Insert Emoticons


2.1 Small Processing


1> Click on the expression to cancel highlighting

Method One: Override the button's sethighlighted: Method

Method two: Self.adjustsimagewhenhighlighted= no; When the button is highlighted, do not adjust the picture (do not adjust the picture will be gray)

2>popview disappears

GCD delay after removal


2.2 Inserting the expression idea


Implementation: Click the Emoji button to insert the expression into the TextView in the controller

Method One: Use the proxy, but the hierarchy is too deep, to get TextView only through the controller, you need to constantly use the agent to pass out:

Hwemotionpageview--hwemotionlistview--hwemotionkeyboard--hwcomposeviewcontroller--hwemotiontextview

Method Two: The use of notification, by the system management, the expression button click Send Notification, controller to receive notifications






Key: Use nsattributedstring to mix the picture and text!!!

Note 1: Picture and text Mix preferably in the textView processing, do not directly in the controller processing

Note 2 : You should not directly place an action that handles emoticons Wbtextview , or the direct and hwemotion Association, causing Wbtextview can only be used in the current project, you should customize a TextView , inherited from Wbtextview , designed to handle emoticons




3. Package TextView


1> Write a Uitextview classification, package Insertattributetext: Method, you can insert with attribute text

Note: But the font settings should not be encapsulated inside






2> rewrite Setattributetext method, guarantee input expression, delete placeholder




3> Add Delete button

Note: When adding a button to the initWithFrame: method, the first button in the layout is the Delete button, not the emoticon button, note subviews


4. Bug Fixes


4.1 Delete Operations




4.2 Keyboard above the tool bar position




Issue: When using the Chinese keyboard, the keyboard height will be high (prompt Chinese), click on the emoji keyboard again, the toolbar position will not change

Cause: The Switchingkeybaord is set

Workaround: Let the toolbar react to the newly popped keyboard!!!




That is: When the old keyboard exits, do not change the frame, and then new keyboard pop-up and then respond to the new keyboard


4.3 emoji becomes smaller


When you insert an emoticon, the image becomes smaller and the text becomes smaller.

Cause: When inserting emoticons, set the font and manipulate after inserting emoticons




If you put in the Insert attribute text inside the operation will not appear to be small, that is, set the font first, and then assign a value to the Self.attributedtext line




That is: Once self.attributedtext= attributedtext, and then removed to set the font on the outside is not good to make!

Key reasons: Self.attributedtext the property is Copy property, for copy properties, the outer text is changed to not affect the text inside

However, it is not appropriate to put the font in the inside, because the method is only used to insert attribute text, do not need tube font

Workaround: Use Block , put the font-setting code in the Block inside!!!






5, hair with facial expression Micro Bo


Method: Convert all image emoticons to text description, send to Sina

1>hwemotiontextview provides a way to convert all picture text in TextView to NSString




Key: Traverse Attributedtext , find all the image expressions, translate them into text description!!!

Note: The current Attch You can only get the settings. UIImage , in order to from Attch To get the original settings Emotion the expression in the description, that is to achieve to get Attach we can get the corresponding Emotion , you can customize hwemotionattachment , adding a Emotion Property!!!


2> Custom Hwemotionattachment






6. Long press the expression


Implementation: Long press the expression will pop up the corresponding expression Popview, and then drag the time to display the corresponding expression Popview

Method: Add long press gesture to PageView

Note 1 : the Display Popview The code is encapsulated in the Wbemotionpopview , pass it to an emoticon button

Note 2 : Originally Wbemotionpopview set the expression model in the method can be removed, directly set the expression button can be

1>hwemotionpopview




2>hwemotionpageview








7. Emoji Keyboard Recent tab


Note 1: To store the most recently used emoticons in a sandbox

Note 2: Deposit the Sandbox when the emoticon button is clicked or long pressed to release

Note 3: Provide a Wbemotiontool management emoticons store, remove






Note: mjcodingimplementation a macro can replace the following two methods


Storage in Hwemotionpageview




Read in Hwemotionkeyboard




iOS Development-No. 05-Projects-10-tweet

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.