Improvement method for realizing chat room message scrolling effect of live broadcast room by iOS
By utilizing the insertion characteristics of UITableView and overall list flip in the live broadcast room chat room, combined with the use of local buffers and timers, the problem of unsmooth message scrolling effect and memory overload is solved, and a more stable and smooth live broadcast barrage experience is achieved.
Patent Information
- Application Number
- CN202510088336.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-01-20
- Publication Date
- 2025-05-13
AI Technical Summary
The existing technology has poor message scrolling effect in the chat room of the live broadcast room, which is prone to lag and memory surge, especially when the number of barrage or abnormal server, it is difficult to ensure a good user experience.
Simplify insertion operations by inserting data forward by leveraging the insertion characteristics of the UITableView, making new data appear at the top of the list and correcting it with overall list flip and single cell display. At the same time, add local buffers to store barrage messages, and insert data regularly through timers to control data volume limits and avoid memory overload.
It achieves a smoother barrage scrolling effect, reduces performance overhead, avoids lag caused by frequent operations, and ensures the stability and user experience of live barrage.
Smart Images

Figure CN119996717A_ABST
Abstract
Description
Technical Field
[0001] The present invention belongs to the technical field of implementing a live broadcast chat room message scrolling effect on iOS, and specifically is an improved method for implementing a live broadcast chat room message scrolling effect on iOS. Background Art
[0002] The improvement of the scrolling effect of the bullet screen in the chat room of the live broadcast room focuses on key goals. First, ensure that the animation is natural and smooth without jumping, giving users a comfortable visual experience; second, the scrolling speed is carefully adjusted to match the reading rhythm of most users. In addition, it attaches importance to the real-time display, and does not allow a large backlog of messages in the display queue. When the instantaneous bullet screen volume increases dramatically, some are decisively discarded according to reasonable priority rules to balance display and resource utilization. This optimization is committed to creating a high-quality bullet screen interactive experience for users of the live broadcast room, effectively promoting user retention, and enhancing the overall attractiveness and vitality of the live broadcast room.
[0003] The live broadcast room uses native UITableView as a list for barrage processing. New barrage messages are inserted at the end of the list, and the corresponding method is called to scroll them to the visible area. At the same time, the server limits the number of barrage messages sent, and sends messages in groups within a short period of time to reduce the number of client refreshes. The client refreshes the received messages in groups and displays them in full, thereby optimizing the barrage display effect and improving the user experience.
[0004] This solution has many shortcomings. UITableView needs to actively call methods to insert data. Frequent calls when there are a large number of bullet screens will cause freezes and too fast scrolling, affecting the experience. Server-side restrictions and grouping are uncontrollable. Abnormal server-side sending of a large number of messages can easily cause memory usage to soar, and the group display is visually incoherent. Furthermore, if a group of messages is refreshed at a time, if the number is too large, some messages will scroll away before the user can see them clearly. These shortcomings make it difficult to ensure a good bullet screen display effect and user experience in scenarios such as a large number of bullet screens and server abnormalities. Summary of the invention
[0005] The purpose of the present invention is to provide an improved method for implementing the message scrolling effect of a live chat room on iOS, so as to solve the problems raised in the above-mentioned background technology.
[0006] In order to achieve the above-mentioned purpose, the present invention provides the following technical solution: The specific steps of the improved method for realizing the message scrolling effect of the live chat room in iOS are as follows:
[0007] S1: Using the UITableView insertion feature: Based on the feature that the contentOffset of UITableView remains unchanged after inserting data, it is determined that inserting data forward can make the new data appear at the top of the list;
[0008] S2: Overall list flip adjustment: Due to the needs of the live chat room, the entire UITableView is flipped up and down, and the logic of displaying the data position is changed;
[0009] S3: Single Cell display correction: Correct the inverted text content caused by overall flipping, and flip each row of cells upside down;
[0010] S4: Simplify insert operations: insert data forward only, without complex scrolling operations to display new data;
[0011] S5: Barrage message buffer setting: add a local buffer to store received barrage messages;
[0012] S6: Insert data at a scheduled time: Start the timer, take 2-3 messages from the buffer every 0.5 seconds and insert them into the list data source for display, match the server frequency and control the buffer data volume;
[0013] S7: Data volume limit maintenance: Set maximum quantity limits for the buffer and data source respectively, and discard the first half of the message when the limit is exceeded to ensure memory stability and message effectiveness.
[0014] Preferably, the specific steps of using the UITableView insertion feature in S1 are as follows:
[0015] Step 1: Analysis of UITableView insertion characteristics: In-depth study of the characteristics of UITableView, clarify the change rules of contentOffset when inserting data, that is, the data list does not move when inserting data backwards, and the original data will move downward to ensure that the contentOffset remains unchanged when inserting data forward, so as to determine the feasibility of using forward insertion to realize the top of new data;
[0016] Step 2: Insert operation implementation: When new data needs to be inserted into UITableView, according to the established strategy, the data is directly inserted to the front of the list. In this way, the newly inserted data can be directly displayed at the top of the list by utilizing the UITableView's own mechanism, without the need for additional complex layout adjustment operations;
[0017] Step 3: Effect verification and optimization: Verify the display effect of UITableView, check whether the newly inserted data is correctly displayed at the top, and confirm the layout, scrolling and other related functions of the overall list. If any abnormalities are found, such as display abnormalities and scrolling jams, optimize and adjust the code in time to ensure the stable operation of the solution and a good user experience.
[0018] Preferably, the overall list flipping adjustment in S2 means that the latest message of the live chat room at the bottom of the list does not meet the requirements, so the entire tableView is flipped up and down, so that the top data becomes the bottom, and after the forward insertion and change of direction, the moving direction of the original data is also changed accordingly to meet the display needs.
[0019] Preferably, the single Cell display correction in S3 refers to flipping each row of cells up and down again. Such a clever design not only achieves the up and down flipping effect of the tableView as a whole, but also ensures that the text display in a single cell returns to normal and meets the expected display.
[0020] Preferably, the simplified insertion operation in S4 means that after the above processing, when inserting data, there is no need to insert it backward and scroll to the bottom as originally done, but only need to insert it forward, and there is no need to call the scrolling method, which makes the operation easier.
[0021] Preferably, the bullet screen message buffer setting in S5 refers to adding a local buffer and putting the received bullet screen message into the buffer.
[0022] Preferably, the specific steps of inserting data at regular intervals in S6 are as follows:
[0023] Step 1: Timer start: Start a timer and set its interval to trigger once every 0.5 seconds to prepare for the subsequent extraction of messages from the buffer;
[0024] Step 2: Message extraction and insertion: According to the established frequency, 2-3 messages are selected from the buffer each time, and these messages are inserted into the list data source to realize message display;
[0025] Step 3: Data volume control: Rely on the above frequency operation to make it basically the same as the frequency sent by the server, thereby ensuring that under normal circumstances, the amount of data in the buffer can be maintained at a small level.
[0026] Preferably, the specific steps of maintaining the data volume limit in S7 are as follows:
[0027] Step 1: Set the buffer limit: Set the maximum number of messages in the buffer to 100 to regulate the upper limit of the messages it can accommodate and avoid unlimited storage;
[0028] Step 2: Buffer message discarding: When too many messages are received and the buffer is overloaded, half of the messages are discarded from the front, with those that have not been displayed for a long time being discarded first to ensure the effectiveness of the backlog of messages;
[0029] Step 3: Maintain the total limit of the data source: Set a limit on the total amount of data source messages. Once the limit is exceeded, clear the first half of the data to prevent the memory from increasing over time.
[0030] The beneficial effects of the present invention are as follows:
[0031] 1. The present invention adopts a smoother bullet screen scrolling solution, which only requires insertion operation and no need to call the scrolling method, greatly saving performance overhead and making the scrolling natural and smooth. Compared with the previous two-step operation of insertion and scrolling, the present invention uses one step instead to reduce the jamming. In this way, the performance loss caused by frequent operations is avoided, and the bullet screen scrolling effect is significantly improved, so that users can watch the bullet screen content in the live broadcast more comfortably.
[0032] 2. The present invention adds a message queue through the client, stores the received messages in the local buffer, and regularly takes a small amount of messages per second for display. This can avoid large-scale refreshes that cause users to miss messages, and can also deal with the situation where the server sends an abnormally large number of messages, effectively enhancing the program's ability to deal with special situations, preventing adverse effects from occurring, and ensuring the stability of the live broadcast barrage experience.
[0033] 3. The present invention reduces the problem of messages scrolling too fast and suddenly making it difficult for users to see clearly, and can also ensure good display effects when there are too many messages. At the same time, it enhances the robustness of the program and avoids memory and performance problems caused by too many messages. Overall, it creates a stable and smooth live broadcast barrage environment for users, allowing users to better participate in the interaction in the live broadcast room and enjoy the viewing process. BRIEF DESCRIPTION OF THE DRAWINGS
[0034] Figure 1 A flow chart of an improved method for implementing a live chat room message scrolling effect on iOS of the present invention;
[0035] Figure 2 This is a mirror image of the bullet screen data of the present invention;
[0036] Figure 3 Schematic diagram of the bullet screen data processing of the present invention. DETAILED DESCRIPTION
[0037] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0038] like Figures 1 to 3 As shown, the embodiment of the present invention provides an improved method for implementing the message scrolling effect of a live chat room in iOS. The specific steps are as follows:
[0039] S1: Using the UITableView insertion feature: Based on the feature that the contentOffset of UITableView remains unchanged after inserting data, it is determined that inserting data forward can make the new data appear at the top of the list;
[0040] S2: Overall list flip adjustment: Due to the needs of the live chat room, the entire UITableView is flipped up and down, and the logic of displaying the data position is changed;
[0041] S3: Single Cell display correction: Correct the inverted text content caused by overall flipping, and flip each row of cells upside down;
[0042] S4: Simplify insert operations: insert data forward only, without complex scrolling operations to display new data;
[0043] S5: Barrage message buffer setting: add a local buffer to store received barrage messages;
[0044] S6: Insert data at a scheduled time: Start the timer, take 2-3 messages from the buffer every 0.5 seconds and insert them into the list data source for display, match the server frequency and control the buffer data volume;
[0045] S7: Data volume limit maintenance: Set maximum quantity limits for the buffer and data source respectively, and discard the first half of the message when the limit is exceeded to ensure memory stability and message effectiveness.
[0046] This solution optimizes the bullet screen display in many aspects around UITableView. The forward insertion strategy is determined by using its insertion characteristics, and the required layout is achieved through list flipping and Cell correction. A buffer is set to buffer messages, and a timed insertion is used to control the rhythm. A data limit is set to maintain memory and message effectiveness. The overall collaboration builds a smooth, stable and efficient live broadcast room bullet screen interactive experience
[0047] The specific steps of using the UITableView insertion feature in S1 are as follows:
[0048] Step 1: Analysis of UITableView insertion characteristics: In-depth study of the characteristics of UITableView, clarify the change rules of contentOffset when inserting data, that is, the data list does not move when inserting data backwards, and the original data will move downward to ensure that the contentOffset remains unchanged when inserting data forward, so as to determine the feasibility of using forward insertion to realize the top of new data;
[0049] Step 2: Insert operation implementation: When new data needs to be inserted into UITableView, according to the established strategy, the data is directly inserted to the front of the list. In this way, the newly inserted data can be directly displayed at the top of the list by utilizing the UITableView's own mechanism, without the need for additional complex layout adjustment operations;
[0050] Step 3: Effect verification and optimization: Verify the display effect of UITableView, check whether the newly inserted data is correctly displayed at the top, and confirm the layout, scrolling and other related functions of the overall list. If any abnormalities are found, such as display abnormalities and scrolling jams, optimize and adjust the code in time to ensure the stable operation of the solution and a good user experience.
[0051] This UITableView bullet screen display solution is divided into three steps. First, its insertion characteristics are deeply analyzed to understand the change rules of contentOffset and clarify the feasibility of forward insertion and pinning. Then, new data is inserted in front of the list according to the strategy and presented through its own mechanism. Finally, the effect is verified, and the layout and scrolling functions are comprehensively checked. Once display or freeze abnormalities are detected, the code is immediately optimized to ensure the stable operation of the solution and give users a high-quality bullet screen viewing experience.
[0052] Among them, the overall list flipping adjustment in S2 means that the latest message of the live chat room at the bottom of the list does not meet the requirements. For this reason, the entire tableView is flipped up and down. In this way, the top data becomes the bottom, and after the forward insertion and change of direction, the moving direction of the original data is also changed accordingly to meet the display needs.
[0053] Because the position of the latest message in the live chat room does not meet the requirements, the tableView is flipped up and down to cleverly change the data position, insertion direction, and movement direction of the original data, effectively meeting the actual needs of the barrage display.
[0054] Among them, the single Cell display correction in S3 refers to flipping each row of cells up and down again. Such a clever design not only achieves the up and down flipping effect of the tableView as a whole, but also ensures that the text display in a single cell returns to normal and meets the expected display.
[0055] After the tableView is flipped as a whole, the design of flipping each row of cells upside down is ingenious. This operation not only turns the tableView upside down as a whole, but also accurately corrects the direction of the text in a single cell, ultimately achieving an ideal visual presentation effect that meets the expectations of the live broadcast room barrage display.
[0056] The simplified insertion operation in S4 means that after the above processing, when inserting data, there is no need to insert it backward and scroll to the bottom as originally done, but only need to insert it forward, and there is no need to call the scrolling method, which makes the operation easier.
[0057] After optimization, the method of barrage insertion has been innovated. Instead of the tedious backward insertion and scrolling to the bottom, it is changed to forward insertion and scroll-free method call. The steps are simplified, and the operation convenience is greatly improved, which improves the efficiency of barrage processing in the live broadcast room.
[0058] The bullet screen message buffer setting in S5 refers to adding a local buffer and putting the received bullet screen message into the buffer.
[0059] Add a local buffer as a storage container for bullet screen messages to facilitate subsequent orderly processing and display.
[0060] The specific steps of inserting data at regular intervals in S6 are as follows:
[0061] Step 1: Timer start: Start a timer and set its interval to trigger once every 0.5 seconds to prepare for the subsequent extraction of messages from the buffer;
[0062] Step 2: Message extraction and insertion: According to the established frequency, 2-3 messages are selected from the buffer each time, and these messages are inserted into the list data source to realize message display;
[0063] Step 3: Data volume control: Rely on the above frequency operation to make it basically the same as the frequency sent by the server, thereby ensuring that under normal circumstances, the amount of data in the buffer can be maintained at a small level.
[0064] The bullet comment processing flow includes three steps: first, start the timer, which is triggered every 0.5 seconds; then, select 2-3 messages from the buffer and insert them into the data source for display; finally, balance the server through frequency regulation to keep the buffer data volume at a low level.
[0065] The specific steps for maintaining the data volume limit in S7 are as follows:
[0066] Step 1: Set the buffer limit: Set the maximum number of messages in the buffer to 100 to regulate the upper limit of the messages it can accommodate and avoid unlimited storage;
[0067] Step 2: Buffer message discarding: When too many messages are received and the buffer is overloaded, half of the messages are discarded from the front, with those that have not been displayed for a long time being discarded first to ensure the effectiveness of the backlog of messages;
[0068] Step 3: Maintain the total limit of the data source: Set a limit on the total amount of data source messages. Once the limit is exceeded, clear the first half of the data to prevent the memory from increasing over time.
[0069] This solution ensures reasonable and orderly message processing from three aspects. First, the buffer quantity is limited to 100 to control storage. Second, when the quantity exceeds the limit, the first half of the message is discarded to ensure effectiveness. Third, the total amount of data source is limited. When the limit is exceeded, the first half of the data is cleared to prevent memory expansion. The overall optimization effect is significant.
[0070] It should be noted that, in this article, relational terms such as first and second, etc. are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Moreover, the terms "include", "comprise" or any other variants thereof are intended to cover non-exclusive inclusion, so that a process, method, article or device including a series of elements includes not only those elements, but also other elements not explicitly listed, or also includes elements inherent to such process, method, article or device.
[0071] Although embodiments of the present invention have been shown and described, it will be appreciated by those skilled in the art that various changes, modifications, substitutions and variations may be made to the embodiments without departing from the principles and spirit of the present invention, and that the scope of the present invention is defined by the appended claims and their equivalents.
Claims
1. An improved method for realizing the message scrolling effect of a live chat room on iOS, characterized in that: The specific steps of the iOS method for improving the scrolling effect of live chat room messages are as follows: S1: Using the UITableView insertion feature: Based on the feature that the contentOffset of UITableView remains unchanged after inserting data, it is determined that inserting data forward can make the new data appear at the top of the list; S2: Overall list flip adjustment: Due to the needs of the live chat room, the entire UITableView is flipped up and down, and the logic of displaying the data position is changed; S3: Single Cell Display Correction: Correct the inverted text caused by overall flipping, and flip each cell upside down; S4: Simplify insert operations: insert data forward only, without complex scrolling operations to display new data; S5: Barrage message buffer setting: add a local buffer to store received barrage messages; S6: Insert data at a scheduled time: Start the timer, take 2-3 messages from the buffer every 0.5 seconds and insert them into the list data source for display, match the server frequency and control the buffer data volume; S7: Data volume limit maintenance: Set maximum quantity limits for the buffer and data source respectively, and discard the first half of the message when the limit is exceeded to ensure memory stability and message effectiveness.
2. The improved method for realizing the message scrolling effect of a live chat room in iOS according to claim 1 is characterized in that: The specific steps of using the UITableView insertion feature in S1 are as follows: Step 1: Analysis of UITableView insertion characteristics: In-depth study of the characteristics of UITableView, clarify the change rules of contentOffset when inserting data, that is, the data list does not move when inserting data backwards, and the original data will move downward to ensure that the contentOffset remains unchanged when inserting data forward, so as to determine the feasibility of using forward insertion to realize the top of new data; Step 2: Insert operation implementation: When new data needs to be inserted into UITableView, according to the established strategy, the data is directly inserted to the front of the list. In this way, the newly inserted data can be directly displayed at the top of the list by utilizing the UITableView's own mechanism, without the need for additional complex layout adjustment operations; Step 3: Effect verification and optimization: Verify the display effect of UITableView, check whether the newly inserted data is correctly displayed at the top, and confirm the layout, scrolling and other related functions of the overall list. If any abnormalities are found, such as display abnormalities and scrolling jams, optimize and adjust the code in time to ensure the stable operation of the solution and a good user experience.
3. The improved method for realizing the message scrolling effect of a live chat room in iOS according to claim 1 is characterized in that: The overall list flipping adjustment in S2 means that the latest message in the live chat room is at the bottom of the list, which does not meet the requirements. For this reason, the entire tableView is flipped up and down. In this way, the top data becomes the bottom, and after the forward insertion and change of direction, the moving direction of the original data is also changed accordingly to meet the display needs.
4. The improved method for realizing the message scrolling effect of a live chat room in iOS according to claim 1 is characterized in that: The single Cell display correction in S3 refers to flipping each row of cells up and down again. This clever design not only achieves the up and down flipping effect of the tableView as a whole, but also ensures that the text display in a single cell returns to normal, in line with the expected display.
5. The improved method for realizing the message scrolling effect of live chat room in iOS according to claim 1 is characterized in that: The simplified insertion operation in S4 means that after the above processing, when inserting data, there is no need to insert it backward and scroll to the bottom as originally done, but only need to insert it forward, and there is no need to call the scroll method, which makes the operation easier.
6. The improved method for realizing the message scrolling effect of a live chat room in iOS according to claim 1, characterized in that: The bullet screen message buffer setting in S5 refers to adding a local buffer and putting the received bullet screen message into the buffer.
7. The improved method for realizing the message scrolling effect of live chat room in iOS according to claim 1, characterized in that: The specific steps of inserting data regularly in S6 are as follows: Step 1: Timer start: Start a timer and set its interval to trigger once every 0.5 seconds to prepare for the subsequent extraction of messages from the buffer; Step 2: Message extraction and insertion: According to the established frequency, 2-3 messages are selected from the buffer each time, and these messages are inserted into the list data source to realize message display; Step 3: Data volume control: Rely on the above frequency operation to make it basically the same as the frequency sent by the server, thereby ensuring that under normal circumstances, the amount of data in the buffer can be maintained at a small level.
8. The improved method for realizing the message scrolling effect of live chat room in iOS according to claim 1, characterized in that: The specific steps for maintaining data volume limit in S7 are as follows: Step 1: Set the buffer limit: Set the maximum number of messages in the buffer to 100 to regulate the upper limit of the messages it can accommodate and avoid unlimited storage; Step 2: Buffer message discarding: When too many messages are received and the buffer is overloaded, half of the messages are discarded from the front, with those that have not been displayed for a long time being discarded first to ensure the effectiveness of the backlog of messages; Step 3: Maintain the total limit of the data source: Set a limit on the total amount of data source messages. Once the limit is exceeded, clear the first half of the data to prevent the memory from increasing over time.