Optimization method for iOS editor interface snapshot and realization of notebook mode backspacing, terminal and storage medium
Through persistent storage of view snapshots and JSON data model, the problem of incomplete state recovery and storage redundancy of iOS view controllers is solved, efficient view serialization and recovery is achieved, application performance and user experience are improved, and cross-border view support is supported. Use of platform data.
Patent Information
- Application Number
- CN202411137367.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2024-08-19
- Publication Date
- 2024-12-10
AI Technical Summary
The existing iOS technology relies on system callbacks when the view controller state is restored, and there are uncontrollable factors, resulting in incomplete recovery, and a large number of image resources are serialized, resulting in waste of storage redundancy.
By generating view snapshots and using JSON data model for persistent storage, recording UI data changes, using stack push and stack rolling mechanisms to achieve backing, and performing full serialization and deserialization when needed.
It realizes a more efficient view serialization solution, saves storage space, improves recovery speed, improves application performance and user experience, and supports cross-platform data migration.
Smart Images

Figure CN119106003A_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to an iOS editor interface snapshot and an optimization method, a terminal and a storage medium for realizing notepad mode rollback. Background Art
[0002] In the iOS operating system, UIViewControllerRestoration is an API for iOS to save UI scenes, which can be saved on the spot when switching between the foreground and background or when the application is suspended. It can save the view controller hierarchy of the current application and restore it to the previous state after the application is terminated.
[0003] NSKeyedArchiver and NSKeyedUnarchiver are combined with the NSCoding protocol to implement the view preservation and restoration scheme: Use NSKeyedArchiver to encode the view controller and its state into binary data and save it to the appropriate storage location. When the view state needs to be restored, use NSKeyedUnarchiver to decode the view controller and its state from the saved binary data and use it to restore the state of the user interface.
[0004] The disadvantages of the prior art solutions are as follows: 1. Relying on system callbacks, there are uncontrollable factors. In some cases (such as the application is suspended and then killed by the system), the system may not be able to fully restore the state of the view controller, which may cause unexpected behavior or user experience problems.
[0005] 2. All view data will be serialized into binary data. If there are a large number of image resources on the interface, they will also be serialized into binary files. These image resources have been stored on the disk. If serialized, the data will be stored multiple times, resulting in redundant storage and waste. Summary of the invention
[0006] The present invention aims to solve the problems existing in the above-mentioned prior art and provides an iOS editor interface snapshot and an optimization method, terminal and storage medium for realizing notepad mode rollback.
[0007] The technical solutions adopted in the present invention are: An iOS editor interface snapshot and an optimization method for implementing notepad mode fallback include the following steps: S1: Enter the editing interface of the editor. If the editing interface has previously persistently stored view data, generate a UI view corresponding to the saved view data; S2: When a user generates a new operation event in the editor, the view data before the change and the view unique ID corresponding to the view data are aggregated into a new data model and pushed into a stack, and the changed UI view is displayed at the same time; S3: During the operation of the editor, if there is a rollback event, a pop-up operation is performed, and the UI data model before the last UI change recorded at the top of the stack is returned, a view is converted from the UI data model, and then the corresponding UI view is found according to the view ID and the existing UI view is replaced, and the changed UI view is displayed; S4: When a save event occurs, the currently displayed UI view is converted into a data model, and the data model is serialized into JSON type data for full persistent storage.
[0008] Furthermore, in S1, if the editing interface has previously persistently stored view data, the saved JSON type view data is deserialized into the memory object model of the UI view, and finally all UI views corresponding to the saved view data are generated.
[0009] Furthermore, in S2, the new operation event includes: creating a new editing view in the editor or entering an existing editing interface to generate a new operation.
[0010] Furthermore, in S2, when the user generates a new operation event in the editor, the listener is notified to inform the editor of the UI view change, and the editor UI view before the change is converted into view data.
[0011] Furthermore, after S2 is completed, if there is no rollback event, it continues to wait for a new operation event to occur and repeats S1 and S2.
[0012] Furthermore, after S3 is completed, if there is no save event, the process continues to wait for a new operation event to occur and repeats S1 to S3.
[0013] The present invention also discloses a terminal, comprising a memory and a processor, wherein a computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the above method.
[0014] The present invention also discloses a storage medium on which a computer program is stored. When the computer program is executed by a processor, the steps of the above method are implemented.
[0015] The present invention has the following beneficial effects: 1) The present invention provides a more efficient view serialization solution, which can save storage space and quickly save and restore view snapshots, which means smaller storage space usage and faster serialization and deserialization speeds, which is crucial to application performance and user experience.
[0016] 2) The solution of the present invention can be used in conjunction with the YYModel framework to achieve fast conversion between view object models and JSON type data. In addition, it can be combined with incremental loading technology to achieve faster loading speed when restoring views. The optimization of this solution will bring significant improvements to the performance, storage utilization and user experience of iOS applications.
[0017] 3) The present invention can solve the problems of how to monitor view changes in UIViewController and how to quickly retrieve data-bound views when a large number of views are stored and restored.
[0018] 4) The present invention can achieve more efficient data management and better user experience by recording UI data through a data model, can increase the performance and scalability of the application, and simplify data operation and maintenance.
[0019] 5) Maintaining UI views through JSON data class records can also achieve cross-platform portability of UI editing data. The data generated on the mobile terminal can be reused on the PC terminal, improving the efficiency of editing data. BRIEF DESCRIPTION OF THE DRAWINGS
[0020] Figure 1 It is a flow chart of the present invention. DETAILED DESCRIPTION
[0021] The present invention will be further described below in conjunction with the accompanying drawings.
[0022] The present invention provides an iOS editor interface snapshot and an optimization method for implementing a notepad mode rollback. When an operation is performed in the editor and the content in the editor changes, the data can be processed and cached by the method of the present invention. The nodes in the view tree and the change order are dynamically mapped to the data model and the intermediate state is recorded. When rollback is required, the saved data is loaded into the editor. Figure 1 , the method of the present invention comprises the following steps: S1) Enter the editor and determine whether the edit interface has view data persistently stored from the last edit.
[0023] S2) If the last saved view data exists, read the JSON data corresponding to the saved view data into the memory; if not, proceed to S5).
[0024] S3) Deserializes from JSON data into an in-memory object model for the UI view.
[0025] S4) generates all UI views of the corresponding data model, and then enters S5).
[0026] S5) Create a new editing view in the editor or enter an existing editing scene and generate an operation event.
[0027] S6) Determine the type of operation event, which mainly includes adding a view or other attribute changes that cause view changes; after determining the type of operation event, two steps are performed simultaneously, one step enters S7) and the other step enters S13).
[0028] S7) Notify the listener of the interface change and convert the UI view before the change into a data model.
[0029] S8) Aggregate the view data before the data change and the unique ID corresponding to the view data into a new data model, and push it into a stack for use when the operation is rolled back.
[0030] S9) Determine whether there is an external trigger event, which may be to roll back or continue to change page elements.
[0031] S10) If it is a new data change, continue to repeat S5)-S9) operations.
[0032] S11) If there is a rollback event, a pop operation is performed to return the UI data model before the last UI change recorded at the top of the stack.
[0033] S12) Convert the view from the UI data model, then find the corresponding UI view according to the view ID and replace the existing UI view.
[0034] S13) Displaying the changed UI view.
[0035] S14) Whether there is an edit completion event (i.e. saving).
[0036] S15) If the editing is completed, data model conversion is performed on all view data constituting the UI view on the editing interface.
[0037] S16) Convert the data model into corresponding JSON format data.
[0038] S17) Persistent JSON format data.
[0039] The present invention generates a unique id for each view, which is used as a key for storing rollback stack data in memory. When a subsequent view is changed, the view before the change is digitized and recorded for use when the operation is rolled back.
[0040] When the editing is completed (click Save), the data model corresponding to the view is converted to JSON type data for full serialization and storage. If the UI view needs to be displayed again (the next time you enter the editor page to edit the saved page), the view tree of the entire UIViewController is fully reversed.
[0041] The solution of the present invention can migrate the saved model to Android or PC platform for further editing. Serialize UI properties into JSON, such as font size, font, background color, view size, and relative position (each node to its parent node). If you want to edit this data on other platforms, just map the corresponding properties to the UI capabilities of the corresponding platform. When storing data, the size of the editing canvas of each UI element will also be recorded. In this way, the view can be restored on other platforms based on the recorded pixel size, or it can be restored based on the characteristics of the overall migration platform.
[0042] An embodiment of the present invention provides a terminal, which includes a computer program stored in a readable memory, wherein the computer program includes program instructions. When the program instructions are executed by the terminal, the terminal can execute the methods provided by the above method embodiments.
[0043] An embodiment of the present invention provides a storage medium on which a computer program is stored. The computer program enables a terminal to execute the methods provided by the above method embodiments.
[0044] The above description is only a preferred embodiment of the present invention. It should be pointed out that a person skilled in the art can make several improvements without departing from the principle of the present invention, and these improvements should also be regarded as within the protection scope of the present invention.
Claims
1. An iOS editor interface snapshot and an optimization method for implementing notepad mode fallback, characterized in that: The steps include: S1: Enter the editing interface of the editor. If the editing interface has previously persistently stored view data, generate a UI view corresponding to the saved view data; S2: When a user generates a new operation event in the editor, the view data before the change and the view unique ID corresponding to the view data are aggregated into a new data model and pushed into a stack, and the changed UI view is displayed at the same time; S3: During the operation of the editor, if there is a rollback event, a pop-up operation is performed, and the UI data model before the last UI change recorded at the top of the stack is returned, a view is converted from the UI data model, and then the corresponding UI view is found according to the view ID and the existing UI view is replaced, and the changed UI view is displayed; S4: When a save event occurs, the currently displayed UI view is converted into a data model, and the data model is serialized into JSON type data for full persistent storage.
2. The iOS editor interface snapshot and the optimization method for implementing notepad mode fallback as claimed in claim 1, characterized in that: In S1, if the editing interface has previously persistently stored view data, the saved JSON type view data is deserialized into the memory object model of the UI view, and finally all UI views corresponding to the saved view data are generated.
3. The iOS editor interface snapshot and the optimization method for implementing notepad mode fallback as claimed in claim 1, characterized in that: In S2, the new operation event includes: creating a new editing view in the editor or entering an existing editing interface to generate a new operation.
4. The iOS editor interface snapshot and the optimization method for implementing notepad mode fallback as claimed in claim 1, characterized in that: In S2, when the user generates a new operation event in the editor, the listener is notified to inform the editor of the UI view change, and the editor UI view before the change is converted into view data.
5. The iOS editor interface snapshot and the optimization method for implementing notepad mode fallback as claimed in claim 1, characterized in that: After S2 is completed, if there is no rollback event, it continues to wait for new operation events to occur and repeats S1 and S2.
6. The iOS editor interface snapshot and the optimization method for implementing notepad mode fallback as claimed in claim 1, characterized in that: After S3 is completed, if there is no save event, continue to wait for a new operation event to occur and repeat S1 to S3.
7. A terminal comprising a memory and a processor, characterized in that: A computer program is stored in the memory, and when the computer program is executed by the processor, the processor executes the method according to any one of claims 1 to 6.
8. A storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the steps of the method according to any one of claims 1 to 6 are implemented.
Citation Information
Patent Citations
Page editor interaction apparatus and method
CN105068815A
Method and system for updating object base used for keyword drive test
CN105512044A
Restoration of UI state in transactional systems
CN107924411A
