Create a chat interface and a chat interface

Source: Internet
Author: User

Create a chat interface and a chat interface
Layout of imitation QQ chat

Most of the materials found currently have such results, and the design ideas are the same,

A tableview uses a custom cell. After the cell is successfully created, it uses the data transmitted by an intermediary class to determine whether the data is sent on the left or right, and then re-draws the content or layout.

But xib is not good at code adaptation and layout.

First Interface

Then the custom cell

Although it looks strange, it is a simple and crude method based on the train of thought. In fact, this cell is actually merged when the two sides are separately displayed, through the data intermediary class, you can know that the data on the other side should be displayed, and then hide the data on the other side.

    dataSource.blockConfigureCell=^(CellFour* cell,Message* model)    {        cell.CFMessage=model;        switch (cell.CFMessage.MCellSystle)        {            case CellSystleLeft:            {                cell.headimageRight.hidden=YES;                cell.CFbackGroundRight.hidden=YES;                cell.message.text=model.MDictionary[@"message"];            }                break;                case CellSystleRight:            {                cell.headImage.hidden=YES;                cell.CFbackGroundLeft.hidden=YES;                cell.messageRight.text=model.MDictionary[@"message"];            }                break;            default:                break;        }    };

In fact, this is also a very helpless practice. At the beginning, two custom cells were used, that is, the display cells on the left and right were opened independently, however, two reusable labels will be generated during registration. Even if they are not displayed, the above results can be achieved, however, once you enter the reuse queue, you will only use the latest modified reuse tag. The final result is that all styles become one style regardless of the left or right.

Then I tried again. A custom cell contains two styles. Although the problem of reuse of labels is solved, the problem is the problem of cell creation, this will determine whether the cell is displayed on the left or on the right after creation, but the intermediate class of the cell is passed to tell the cell

The cell has been created when the style is used (cell is empty if data is passed before creation ). It cannot achieve the goal of dynamic adjustment.

The problem is recorded for the moment, so if the two sides want to achieve different display effects, they will be like different bubbles of qq (xib will be more troublesome, but it will be simpler ).

Related Article

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.