CN117873613A - Application page display method and device, electronic equipment and storage medium - Google Patents

Application page display method and device, electronic equipment and storage medium Download PDF

Info

Publication number
CN117873613A
CN117873613A CN202311665742.1A CN202311665742A CN117873613A CN 117873613 A CN117873613 A CN 117873613A CN 202311665742 A CN202311665742 A CN 202311665742A CN 117873613 A CN117873613 A CN 117873613A
Authority
CN
China
Prior art keywords
environment
page
variable
resource
correction
Prior art date
Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
Pending
Application number
CN202311665742.1A
Other languages
Chinese (zh)
Inventor
唐如意
陈裕聪
修怀忠
Current Assignee (The listed assignees may be inaccurate. Google has not performed a legal analysis and makes no representation or warranty as to the accuracy of the list.)
Chongqing Seres New Energy Automobile Design Institute Co Ltd
Original Assignee
Chongqing Seres New Energy Automobile Design Institute Co Ltd
Priority date (The priority date is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the date listed.)
Filing date
Publication date
Application filed by Chongqing Seres New Energy Automobile Design Institute Co Ltd filed Critical Chongqing Seres New Energy Automobile Design Institute Co Ltd
Priority to CN202311665742.1A priority Critical patent/CN117873613A/en
Publication of CN117873613A publication Critical patent/CN117873613A/en
Pending legal-status Critical Current

Links

Landscapes

  • Stored Programmes (AREA)

Abstract

The application relates to the technical field of application management, and provides an application page display method, an application page display device, electronic equipment and a storage medium. According to the method, when a page display instruction is received, the terminal accesses the environment correction recorder, judges whether the current environment of the terminal needs to be corrected, acquires a first environment variable of a page from the environment correction recorder when the current environment of the terminal needs to be corrected, acquires a first resource corresponding to the first environment variable, and further displays an applied page by using the first resource, so that when the current environment of the terminal changes, the environment variable required by page display can be flexibly and efficiently acquired, the resource corresponding to the page display is further acquired, the resources of all conditions of the page display do not need to be preloaded, the volume of an application preloaded resource package is reduced, the utilization efficiency of terminal hardware resources is improved, the page display efficiency of the terminal is improved, and the user experience is improved.

Description

Application page display method and device, electronic equipment and storage medium
Technical Field
The present disclosure relates to the field of application management technologies, and in particular, to an application page display method, an application page display device, an electronic device, and a storage medium.
Background
In the process of application development, in order to improve user experience, service requirements may specify that resources used in an application need to change with changes in the device environment. For example, when the device is in a bright mode, the color matching of the application page may be dominant, and when the device is in a dark mode, the color matching of the application page may be dominant, so that the user can view the application page more clearly.
Currently, in application development based on an apple operating system (iPhone Operating System, iOS), resources corresponding to different environments are usually all pre-stored in a pre-package, that is, in an assembly folder of a project, and the resources corresponding to each environment are set. In this way, the application can automatically select the corresponding resource according to the environment of the current device.
However, this implementation has the following drawbacks:
1) In the pre-package of the application, a plurality of different sets of resources are configured for different environments, and because the resources consume a large amount of storage space, part of the resources may be used less in the actual running of the program, unnecessary storage space is wasted.
2) All resources are stored in the Assets folder, so that the resource sources can only be prefabricated and preloaded, but the resources corresponding to the environment cannot be flexibly modified when being updated.
3) The configuration relation between the resources and the environment can be realized only through prefabrication, and whether the unique environment configuration exists for each page or not can not be dynamically configured, and the existing environment configuration of each page can not be modified.
Disclosure of Invention
In view of this, the embodiments of the present application provide a method, an apparatus, an electronic device, and a storage medium for displaying an application page, so as to solve the problem in the prior art that when the environment where a terminal is located changes, the display change of the application page in the terminal is not efficient and flexible enough.
In a first aspect of an embodiment of the present application, there is provided an application page display method, which is executed by a terminal and includes:
in response to receiving a page display instruction, the terminal accesses an environment correction recorder to determine whether the page needs to be subjected to environment correction, wherein the environment correction recorder comprises a registry of all modules which need to correct the real environment of the terminal in application, and the modules comprise one or more pages;
in response to determining that the page needs to be subjected to environment correction, acquiring a first environment variable of the page from an environment correction recorder, wherein the first environment variable is the corrected environment variable;
Acquiring a first resource corresponding to a first environment variable;
the page of the application is displayed using the first resource.
In a second aspect of the embodiments of the present application, there is provided an application page display device, including:
the environment correction judging module is configured to respond to the received page display instruction, the terminal accesses the environment correction recorder to determine whether the page needs to be subjected to environment correction, wherein the environment correction recorder comprises a registry of all modules which need to be subjected to the correction on the real environment of the terminal in application, and the modules comprise one or more pages;
the environment variable obtaining module is configured to obtain a first environment variable of the page from the environment correction recorder in response to determining that the page needs to be subjected to environment correction, wherein the first environment variable is the corrected environment variable;
the resource acquisition module is configured to acquire a first resource corresponding to a first environment variable;
and a display module configured to display a page of the application using the first resource.
In a third aspect of the embodiments of the present application, there is provided an electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, the processor implementing the steps of the above method when executing the computer program.
In a fourth aspect of the embodiments of the present application, there is provided a computer readable storage medium storing a computer program which, when executed by a processor, implements the steps of the above method.
Compared with the prior art, the embodiment of the application has the beneficial effects that: according to the method and the device, when the page display instruction is received, the terminal accesses the environment correction recorder, judges whether the current environment of the terminal needs to be corrected, acquires the first environment variable of the page from the environment correction recorder when needed, acquires the first resource corresponding to the first environment variable, and further displays the page of the application by using the first resource, so that the environment variable required by the page display can be flexibly and efficiently acquired when the current environment of the terminal changes, the resource corresponding to the page display is further acquired, the resources of all conditions of the page display are not required to be preloaded, the volume of an application preloaded resource package is reduced, the utilization efficiency of terminal hardware resources is improved, the page display efficiency of the terminal is improved, and the user experience is improved.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the following description will briefly introduce the drawings that are needed in the embodiments or the description of the prior art, it is obvious that the drawings in the following description are only some embodiments of the present application, and that other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application.
Fig. 2 is a flowchart of an application page display method according to an embodiment of the present application.
Fig. 3 is a flowchart of a configuration method of an environmental correction recorder according to an embodiment of the present application.
Fig. 4 is a flowchart of another configuration method of an environmental correction recorder according to an embodiment of the present application.
Fig. 5 is a flowchart of a method for determining whether a page needs to be subjected to environmental correction by a terminal when the page provided in the embodiment of the present application is implemented by a single view controller or a single view.
FIG. 6 is a flow chart of a method for obtaining a first environment variable of a page from an environment remediation recorder when the page is implemented by a single view controller or a single view, provided by an embodiment of the present application.
Fig. 7 is a flowchart of a method for determining, by a terminal, whether a page needs to be subjected to environment correction when the page provided in an embodiment of the present application is implemented by a parent-child view controller.
Fig. 8 is a flowchart of a method for determining whether a page needs to be subjected to environment correction by a terminal when the page provided in the embodiment of the present application is implemented by a source view controller and a pop-up view controller.
Fig. 9 is a flowchart of another method for determining whether a page needs to be subjected to environment correction by a terminal according to an embodiment of the present application.
Fig. 10 is a flowchart of another method for determining whether a page needs to be subjected to environmental correction by a terminal when the page provided in the embodiment of the present application is implemented by a single view controller or a single view.
Fig. 11 is a flowchart of a method for obtaining a first resource corresponding to a first environment variable according to an embodiment of the present application.
Fig. 12 is a flowchart of a method for creating a custom resource manager according to an embodiment of the present application.
Fig. 13 is a flowchart of an application page display method according to an embodiment of the present application.
FIG. 14 is a schematic diagram of a relationship between resources and environment-resource configuration provided by an embodiment of the present application.
Fig. 15 is a schematic diagram of an application page display device according to an embodiment of the present application.
Fig. 16 is a schematic diagram of an electronic device provided in an embodiment of the present application.
Detailed Description
In the following description, for purposes of explanation and not limitation, specific details are set forth, such as particular system configurations, techniques, etc. in order to provide a thorough understanding of the embodiments of the present application. It will be apparent, however, to one skilled in the art that the present application may be practiced in other embodiments that depart from these specific details. In other instances, detailed descriptions of well-known systems, devices, circuits, and methods are omitted so as not to obscure the description of the present application with unnecessary detail.
An application page display method and device according to embodiments of the present application will be described in detail below with reference to the accompanying drawings.
Fig. 1 is a schematic view of an application scenario according to an embodiment of the present application. The application scenario may include terminal devices 1, 2 and 3, a server 4 and a network 5.
The terminal devices 1, 2 and 3 may be hardware or software. When the terminal devices 1, 2 and 3 are hardware, they may be various electronic devices having a display screen and supporting communication with the server 4, including but not limited to smart phones, tablet computers, laptop portable computers, desktop computers, and the like; when the terminal apparatuses 1, 2, and 3 are software, they can be installed in the electronic apparatus as described above. The terminal devices 1, 2 and 3 may be implemented as a plurality of software or software modules, or may be implemented as a single software or software module, which is not limited in this embodiment of the present application. Further, various applications, such as a data processing application, an instant messaging tool, social platform software, a search class application, a shopping class application, and the like, may be installed on the terminal devices 1, 2, and 3.
The server 4 may be a server that provides various services, for example, a background server that receives a request transmitted from a terminal device with which communication connection is established, and the background server may perform processing such as receiving and analyzing the request transmitted from the terminal device and generate a processing result. The server 4 may be a server, a server cluster formed by a plurality of servers, or a cloud computing service center, which is not limited in this embodiment of the present application.
The server 4 may be hardware or software. When the server 4 is hardware, it may be various electronic devices that provide various services to the terminal devices 1, 2, and 3. When the server 4 is software, it may be a plurality of software or software modules providing various services to the terminal devices 1, 2, and 3, or may be a single software or software module providing various services to the terminal devices 1, 2, and 3, which is not limited in the embodiment of the present application.
The network 5 may be a wired network using coaxial cable, twisted pair and optical fiber connection, or may be a wireless network capable of realizing interconnection of various communication devices without wiring, for example, bluetooth (Bluetooth), near field communication (Near Field Communication, NFC), infrared (Infrared), etc., which is not limited in the embodiment of the present application.
The user can establish a communication connection with the server 4 via the network 5 through the terminal devices 1, 2, and 3 to receive or transmit information or the like. Specifically, the terminal devices 1, 2 and 3 may receive a configuration file from the server 4, configure a registry in the environment correction recorder based on the configuration file, and acquire an environment variable of a current page to be displayed by using the environment correction recorder, thereby acquiring a display resource. On the other hand, the terminal devices 1, 2 and 3 may also send the registry in the environmental remediation recorder to the server 4 to update the configuration file in the server.
It should be noted that the specific types, numbers and combinations of the terminal devices 1, 2 and 3, the server 4 and the network 5 may be adjusted according to the actual requirements of the application scenario, which is not limited in the embodiment of the present application.
As mentioned above, currently, in application development based on the apple operating system (iPhone Operating System, iOS), resources corresponding to different environments are usually all pre-stored in a pre-package, that is, in the packages of the projects, and the resources corresponding to each environment are set. In this way, the application can automatically select the corresponding resource according to the environment of the current device.
For example, a picture may be a resource. In the dark mode, the application display requirements may be: displaying a picture imageA; in bright mode, the application display requirements may be: displaying the picture imageB. When the application is developed, a picture resource reference, for example, called an imageReference, can be newly built in the views folder of the project, then the picture imageA map is configured in a dark mode corresponding to the imageReference, and the picture imageA map is configured in a bright mode corresponding to the imageReference.
However, this implementation has the following drawbacks:
1) In the pre-package of the application, a plurality of different sets of resources are configured for different environments, and because the resources consume a large amount of storage space, part of the resources may be used less in the actual running of the program, unnecessary storage space is wasted. At the same time, the user sees a substantial amount of application packages, hesitation occurs when considering whether to download or not, and popularization of the application is not utilized.
2) All resources are stored in the Assets folder, so that the resource sources can only be prefabricated and preloaded, but the resources corresponding to the environment cannot be flexibly modified when being updated.
3) The configuration relation between the resources and the environment can be realized only through prefabrication, and whether the unique environment configuration exists for each page or not can not be dynamically configured, and the existing environment configuration of each page can not be modified.
In view of this, embodiments of the present application provide an application page display method, where implementing resources with a resource manager has any flexible source, such as: download from the network, create from memory, etc. Meanwhile, by means of correcting the environment, the configuration relation between the environment and the resources can be modified at any time, and the purposes of meeting business requirements, effectively reducing the pre-package volume and flexibly adjusting the displayed resources without limitation are achieved. The technical scheme of the embodiment of the application can be applied to various different services such as skin changing service, internationalization service, regional customized language service, style service and the like of the application, and the realization efficiency of the services can be improved.
Further, the embodiment of the application page display method further provides an environment correction recorder, when a page display instruction is received, the terminal accesses the environment correction recorder, judges whether the current environment of the terminal needs to be corrected, acquires a first environment variable of a page from the environment correction recorder when needed, acquires a first resource corresponding to the first environment variable, and further displays the page of an application by using the first resource, so that when the current environment of the terminal changes, the environment variable required by page display can be flexibly and efficiently acquired, the resource corresponding to the page display is further acquired, preassembling of resources in all conditions of the page display is not needed, the volume of an application preassembled resource package is reduced, the utilization efficiency of terminal hardware resources is improved, the efficiency of page display application in the terminal is improved, and the user experience is improved.
Fig. 2 is a flowchart of an application page display method according to an embodiment of the present application. The application page display method of fig. 2 may be performed by the terminal of fig. 1. As shown in fig. 2, the application page display method includes the steps of:
in step S201, in response to receiving the page display instruction, the terminal accesses the environment correction recorder to determine whether the page requires the environment correction.
The environment correction recorder comprises a registry of all modules which need to correct the real environment of the terminal in the application, wherein the modules comprise one or more pages.
In step S202, in response to determining that the page requires an environmental fix, a first environmental variable of the page is obtained from an environmental fix recorder.
Wherein the first environmental variable is a corrected environmental variable.
In step S203, a first resource corresponding to the first environment variable is acquired.
In step S204, a page of the application is displayed using the first resource.
In the embodiment of the application, the method can be executed by the terminal. Further, the method may be implemented in an operating system of the terminal, where the operating system of the terminal may be, for example, an iOS operating system.
In the embodiment of the application, when the environment where the terminal is located changes, the application in the terminal can update the page display of the terminal. For example, when the screen direction of the terminal changes, the page display such as the picture direction or the like applied in the terminal may also change accordingly. Wherein the change of the environment can be perceived and informed to the application by the operating system of the terminal.
Taking an application as an example of an application developed in the iOS system, the device environment of the terminal is called track Collection, expressed by the UITraitCollection class, which describes the environment in which the iOS device is currently located, including: shading patterns, screen orientation, device type, screen zoom ratio, etc. In the embodiments of the present application, these individual environmental items may be referred to as environmental characteristics. For example, the compare in the screen direction (size Classes) is one environmental characteristic, and the bright mode and the dark mode in the bright-dark mode (user interface idiom) are two different environmental characteristics.
In the related art, when the environment in which the terminal is located changes, the operating system of the terminal senses the change and acquires the changed environment characteristics. For example, if the terminal is a mobile phone and the mobile phone is currently in a landscape mode, the mobile phone operating system may determine that the size Classes of the track collection is in the vertical direction. Then, the application of the mobile phone can acquire the picture resource corresponding to the compact in the pre-package, and display the picture resource on the screen of the terminal.
However, since the service requirements of the terminal are variable, it may not be required to use picture resources corresponding to the compact in the landscape mode for some pages or some modules, that is, the application of the terminal needs to use resources different from those corresponding to the current environmental characteristics in the pre-package to display the pages.
In this embodiment of the present application, an environment correction recorder may be configured at the terminal, so that when the terminal receives the page display instruction, the terminal accesses the environment correction recorder to determine whether the page to be displayed needs to be subjected to environment correction. Taking the application as an example of an application developed in the iOS system, the environment correction recorder may be a class, and further, for convenience of management, the environment correction recorder may be implemented in the form of a tool class and declared as a single instance.
Furthermore, a registry can be maintained in the environment correction recorder, and all the correction modules required to be performed on the real environment in the application can be registered or deregistered in the registry. Wherein a module may include one or more pages.
In the embodiment of the application, the registry may be a linked list or a dictionary. If the registry is a linked list, each linked list item is a class object, and the member variables of the class object include a module identifier (Identity document, id) and a target environment characteristic, where the target environment characteristic may be a description corresponding to a requirement of a service requirement, for example, an environment required by the module, or a resource corresponding to the environment required by the module. If the registry is a dictionary, the key (key) of the dictionary is the module id, and the value (value) is the description corresponding to the target environment characteristic, i.e. the requirement of the service requirement.
In an example, one key in the dictionary may be module idA, and the corresponding value is the environment needed by the module: bright mode, and corresponding picture imageA in bright mode. In another example, member variables in a linked list item may include a module idB, and the circumstances that the module needs: and the horizontal screen is corresponding to the picture imageB in the horizontal screen mode.
The naming rule of the module id can be formulated according to actual needs. In one example, since a module may be made up of one or more pages, the module id may be derived on a page basis, e.g., taking the module name + page name as the module id, an exemplary module id may be derived as follows: logging-in module_logging-in page, logging-in module_forgetting password page, vehicle control module_air conditioning page and vehicle control module_vehicle position page. In another example, the module id may also be derived based on the class name of the page in the item, for example: bluetooth key page: bluetooth key ViewController; authorized vehicle page: authoritzeViewController.
In the embodiment of the application, the module id can be specially managed and allocated by using a tool class and a configuration file. On the other hand, the class name of the page in the item can be directly used as the module id, so that the current class name can be converted into a character string by using a tool provided by the iOS system, and other classes in the application can be called through a system method.
In the embodiment of the application, the registry of the environment correction recorder can register and unregister, wherein the registered entry is a module id and a target environment characteristic (i.e. a description corresponding to the requirement of a service requirement), and the implementation logic of the registration is to add one item to the registry. The registering method comprises the steps of registering a module id, wherein the registering is realized as a dictionary, directly deleting the item with the key equal to the module id in the dictionary, and searching the linked list item with the member variable of the module id equal to the module id in the linked list if the registering is realized as a linked list, and deleting the linked list item. The terminal may access all items of the registry and may also look up an item in the registry based on the module id. When the entry corresponding to the module id is not included in the registry, a null value may be returned.
In the embodiment of the application, the terminal accesses the environment correction recorder, searches whether a registry of the environment correction recorder includes a module id corresponding to a module where the page is located, and if so, determines that the page needs to be subjected to environment correction. Further, the terminal may further obtain a first environmental variable of the page from the environmental correction recorder, where the first environmental variable is obtained by converting, by the terminal, a target environmental characteristic corresponding to a module where the page is located obtained from the environmental correction recorder.
In the embodiment of the invention, after the first environment variable is obtained, the terminal can also use the first environment variable to obtain the first resource corresponding to the first environment variable from the resource manager, and then use the first resource to display the page, so that when the environment where the terminal is located changes, the page display resource is configured in real time according to the actual requirement, and compared with the self-preassembling package downloading fixed display resource in the related art, the flexibility and configuration efficiency of page display are improved.
According to the technical scheme provided by the embodiment of the application, the environment correction recorder is arranged, when the page display instruction is received, the terminal accesses the environment correction recorder, whether the current environment of the terminal needs to be corrected is judged, the first environment variable of the page is acquired from the environment correction recorder when needed, the first resource corresponding to the first environment variable is acquired, and then the page of the application is displayed by using the first resource, so that the environment variable required by the page display can be flexibly and efficiently acquired when the current environment of the terminal changes, the resource corresponding to the page display is further acquired, the preassembly of the resources of all conditions of the page display is not needed, the volume of an application preassembly resource package is reduced, the utilization efficiency of the hardware resource of the terminal is improved, the efficiency of the page display of the application in the terminal is improved, and the user experience is improved.
Fig. 3 is a flowchart of a configuration method of an environmental correction recorder according to an embodiment of the present application. As shown in fig. 3, the method comprises the steps of:
in step S301, in response to the application starting, the environmental remediation recorder acquires an initial profile.
In step S302, the mask item in the initial configuration file is extracted, and the mask item is mapped to the registry.
The registry includes module identification of the module requiring the environment correction and target environment characteristics including descriptions corresponding to the needs of the module service requirements.
In the embodiment of the application, the environment correction recorder can be configured through a configuration file. Specifically, what is recorded in the registry of the environmental remediation recorder is a mask record formulated by the business requirements, i.e., which modules' environmental variables need to be remedied, and how they should be remedied, according to the business requirements. These data may be recorded in a configuration file, which may be stored in a pre-package of the terminal, which is a stationary resource. The storage location of the configuration file includes, but is not limited to, a pre-package of the terminal, a sandbox (the file is put into the sandbox from the pre-package after the program is installed) or a memory; the stored form of the configuration file includes, but is not limited to, an extensible markup language (Extensible Markup Language, xml) file, an attribute table (plist) file, a plain text file, or a binary file.
When an application is started, the environment remediation recorder may obtain the initial configuration file, extract the mask items in the initial configuration file, and map the mask items to the registry. The specific content of the registry obtained by mapping is described in detail above, and will not be described here again.
In the embodiment of the application, in order to increase the implementation flexibility, the server can dynamically update the configuration file in the forms of command, notification and the like, and can distinguish the configuration files in different dimensions according to the dimensions of different users, different areas, different devices and the like.
Fig. 4 is a flowchart of another configuration method of an environmental correction recorder according to an embodiment of the present application. Step S401 to step S402 in the embodiment shown in fig. 4 are substantially the same as step S301 to step S302 in the embodiment shown in fig. 3, and are not described herein. As shown in fig. 4, the method further comprises the steps of:
in step S403, in response to the application receiving the configuration instruction sent by the server at runtime, the registry is updated based on the configuration instruction.
In step S404, the registry in the environmental remediation recorder is written to the configuration file in response to the application ending running, or the application receiving a save registry command.
In this embodiment of the present application, when the application receives a configuration instruction sent by the server during running, the registry may be updated based on the configuration instruction. That is, the environmental remediation recorder may accept configuration from the server, adjust the registry at any time, for example: the server informs the environment correction recorder that a certain item needs to be deleted, and the environment correction recorder can call the self anti-registration method to delete the item; the server informs the environment correction recorder that a certain item needs to be added, and the environment correction recorder can call a registration method of the server to finish registration of the item.
On the other hand, when the application ends running, or the application receives a save registry command, the registry in the environmental remediation recorder may be written to the configuration file. The command of saving the registry received by the application can be sent by the system at regular time or can be sent once according to the requirement. That is, the environmental remediation recorder may write the configuration of the registry to the configuration file at regular intervals. Alternatively, at the end of the application, the context remediation recorder writes the configuration of the registry to the configuration file. Optionally, after writing the configuration of the registry into the configuration file, the terminal may also notify the server that the data update is performed.
In this embodiment of the present application, by accessing the environment correction recorder to determine whether the page needs to be subjected to environment correction, there may be two implementation manners: one is to systematically modify the page structure of the application, i.e. modify the inheritance chain of the whole application page, so that it realizes the environmental correction at the parent layer; the other is to make local modifications directly on the specific module. The former is used in project engineering that has just been created or has not been created because of the need to modify inheritance chains, and in cases where modules that have been created for some time but need to be remedied account for a majority of the total modules of the project. The latter has small modification, and is used in the case that the modules which are created for a period of time and need to be corrected occupy a small number of total modules of the project. The implementation process of determining whether the page needs to be subjected to environment correction by adopting the two modes respectively will be described below.
Pages may be implemented by a single view controller, or by a single view, or by a parent-child view controller, or by a source view controller and a popped view controller. The specific implementation of the terminal to determine whether the page needs to be subjected to environmental remediation may be different for different page implementations.
Fig. 5 is a flowchart of a method for determining whether a page needs to be subjected to environmental correction by a terminal when the page provided in the embodiment of the present application is implemented by a single view controller or a single view. As shown in fig. 5, the method comprises the steps of:
in step S501, a subclass is created for the view controller or view.
The subclasses of the view controllers are base classes of all view controllers in the application, and the subclasses of the views are base classes of all views in the application.
In step S502, a member variable is added to the subclass of the view controller or the subclass of the view.
In step S503, the module identification of the page is acquired.
In step S504, the query results are obtained in the environmental remediation recorder using the module identification.
In step S505, in response to the query result not being null, the value of the member variable is set to true, otherwise the value of the member variable is set to false.
In step S506, the value of the member variable is queried to determine whether the page requires environmental remediation based on the value of the member variable.
In the embodiment of the application, when the page is implemented by a single view controller or a single view, a subclass may be first created for the view controller or the view, and the subclass is a base class of all view controllers or views in the application. Further, the view controller is a view controller in a terminal operating system, and the view is a view in the terminal operating system. That is, a parent view controller may be created for a view controller in an application, or a parent view may be created for a view in an application, such that the environments of child view controllers or child views are specified by the parent view controller or parent view to enable flexible configuration of the environmental characteristics of the pages.
In the embodiment of the application, a member variable can be added for the subclass of the view controller or the subclass of the view, and the module identifier of the page is obtained. And querying in the environment correction recorder by using the acquired module identifier, and acquiring a query result. If the query result is not null, it indicates that the registry of the environment correction recorder has records of the module, and the current page needs to be subjected to environment correction, so that the value of the member variable is set to be true, otherwise, the value of the member variable is set to be false. Further, querying the value of the member variable can determine whether the page requires environmental remediation based on the value of the member variable.
FIG. 6 is a flow chart of a method for obtaining a first environment variable of a page from an environment remediation recorder when the page is implemented by a single view controller or a single view, provided by an embodiment of the present application. As shown in fig. 6, the method includes the steps of:
in step S601, a target environmental characteristic corresponding to a page is acquired from an environmental correction recorder.
In step S602, an environmental characteristic is newly created in the system automatic call method when the environment of the terminal is changed according to the target environmental characteristic.
In step S603, the newly created environment characteristic is assigned to the environment attribute in the system automatic call method, and the first environment variable of the page is obtained.
In this embodiment of the present application, when it is determined that the page needs to be subjected to environmental correction, the target environmental characteristic corresponding to the page may also be obtained from the environmental correction recorder. Further, according to the target environment characteristic, when the environment of the terminal changes, the environment characteristic is newly built in the system automatic call method, and then the newly built environment characteristic is assigned to the environment attribute in the system automatic call method, so that a first environment variable of the page is obtained.
Still taking the application as an example of an application developed in an iOS system, if a page is made up of a single view controller uiiviewcontroller, a subclass may first be generated for uiiviewcontroller, which may be named uiiviewcontroller parent, for example. Uiiviewcontrollerpart needs to be the base class for all view controllers in the application.
Next, a member variable may be added to uiviewcontrollerpart to record whether it needs correction. The member variable may be a Boolean (Bool) variable that takes the value if true (true) meaning that correction is required and if false (false) meaning that correction is not required. The name of the member variable may be set as desired, for example, as isneedledRetort. Further, if most pages in the application do not need correction, the default value of the member variable may be false; conversely, if most pages require correction, the default value for the member variable may be true.
Next, the environment record appliance can be queried whether the environment of the page needs to be corrected by rewriting the uiviiewcontrollerparent's viewdload function, and importing it into the uiviiewcontlerparent. The code of the overwriting method may be:
override func traitCollectionDidChange(_prevtc:UITraitCollection?){
super.traitCollectionDidChange(prevtc)
custom logic
}
The custom logic portion may include a step of obtaining a module id of a module corresponding to the page according to a tool query provided by the iOS system, for example, if the module id is named by using a class name, a nsstring from class function may be used to convert the current class name into a character string to obtain the module id. Then, a method of accessing the environment correction recorder searches a certain item of a registry, and the module id obtained by input query is entered; if the found value is empty, the page is indicated to be directly returned without environment correction; if the found value is not null, it indicates that the page needs to be subjected to environment correction, and at this time, the member variable isneedledort may be set to true.
Finally, in the method traitCollectinDidCHange automatically called by the system when the environment corresponding to UIViewControllerParent changes, the value of the member variable isneedletort is read through the custom logic, and whether the environment correction is needed for the page is further determined. Specifically, the step in the traitCollectinDidCHange method may include a judging step, in which the calling method reads the value of the isneedledRetort, if it is true, it determines that the page needs to be subjected to environment correction, otherwise, it directly returns. Thus, the judgment of whether the page needs to be subjected to environment correction is completed.
Further, the custom logic portion of the traitcollelectiondidchange may further include a step of acquiring a first environment variable of the page. In this step, an environmental characteristic may be newly created, and the value of the environmental characteristic may be the target environmental characteristic corresponding to the page acquired from the environmental correction recorder. As previously described, the environmental remediation recorder includes a registry in which the module identification of the modules that need to be environmentally remediated, as well as the target environmental characteristics of each module, are recorded. When the module id is queried in the environment correction recorder, the target environment characteristic of the module can be acquired, and the target environment characteristic of the page can be determined from the target environment characteristic.
The newly built environment characteristic can be realized by using a UIT collection type constructor. Depending on the nature of the environment that needs to be created, a suitable UIT collection class constructor may be selected to create a specific individual environmental characteristic. For example, an environmental characteristic of one screen zoom ratio may be specified (the actual environmental characteristic may be 4 times): let constitunentDisplay = uitraitcollectionstation (displayScale: uiiscreen. Main. Scale); or may specify the device as an environmental characteristic of the handset (actually possibly a tablet): let constituentPhone =uitraitcollection (userInterfacediom:. Phone). Further, multiple environmental characteristics can be combined into a new environmental characteristic containing multiple characteristics through the constructor of the UIT collection class. For example, the two environmental characteristics described above may be combined: let con-cate=uitraitcollectionstation (traitsFrom: [ continuum display, continuum phone ]).
When the page is formed by a single view UIView, determining whether the page needs to be subjected to environment correction is basically the same as when the page is formed by a single view controller UIViewController, and only the rewritten function is replaced by an init function from a viewdload function, which is not described herein.
Fig. 7 is a flowchart of a method for determining, by a terminal, whether a page needs to be subjected to environment correction when the page provided in an embodiment of the present application is implemented by a parent-child view controller. As shown in fig. 7, the method includes the steps of:
in step S701, a target environmental characteristic corresponding to a page is acquired from an environmental correction recorder using a parent view controller.
In step S702, a system method of a parent view controller is invoked, in which a first environment variable of a page corresponding to a child view controller is configured based on a target environment characteristic.
Parent-child view controllers are a common way of page layout, and a parent view controller may specify the context of any child view controller or controllers of its own. In the embodiment of the application, the parent view controller may be used to acquire the target environment characteristic corresponding to the page from the environment correction recorder, and then a system method of the parent view controller is called, where the first environment variable of the page corresponding to the child view controller is configured based on the target environment characteristic.
Still taking the application as an example of an application developed in an iOS system, a system method func setOverrideTraitCollection (collection: UITraitCollection. The system method accepts two parameters, the first being the environmental characteristics and the second being which sub-view controller is specified.
The implementation code of the system method can be, for example:
let child=xxx
self.addChild(child)
let tc=UITraitCollection(horizontalSizeClass:.compact)
self.setOverrideTraitCollection(tc,forChild:child)
child.view.frame=xxx
self.view.addSubview(child.view)
child.didMove(toParent:self)
wherein the first line of code defines a sub-view controller; the second line of code adds the child view controller to the current parent view controller; the third line of codes sets an environmental characteristic required by the service requirement, namely: the compact in the horizontal direction, namely a mobile phone with a vertical screen or a large mobile phone with a horizontal screen; the fourth row of codes is a key code, and the environment of the child view controller is manually designated by the parent view controller by utilizing the row of codes; the fifth, sixth and seventh lines of code are conventional code for implementing the addition of child view controllers to parent view controllers to form a parent-child relationship.
When the parent view controller manually designates the environment of the child view controller, the designated environment characteristic may be a target environment characteristic corresponding to the page acquired by the parent view controller from the environment correction recorder.
Fig. 8 is a flowchart of a method for determining whether a page needs to be subjected to environment correction by a terminal when the page provided in the embodiment of the present application is implemented by a source view controller and a pop-up view controller. As shown in fig. 8, the method includes the steps of:
in step S801, a target environmental characteristic corresponding to a page is acquired from an environmental correction recorder using a source view controller.
In step S802, a first environment variable of a page corresponding to the pop-up view controller is configured based on a target environment characteristic using the source view controller.
Still taking the application as an example of an application developed in an iOS system, there is a special relationship in the iOS system, in addition to the parent-child view controller: and (5) ejecting. Pop-up refers to one view controller B being popped up by another view controller a, where a is referred to as the source view controller (original ViewController) and B is referred to as the popped view controller (presented ViewController). In this particular relationship, the source view controller may specify the environment of the popped view controller.
When the source view controller pops up, the attribute override traitcollection attribute of the popped up view controller is set. Wherein the override traitcollection attribute is an instance of the UITraitCollection class, i.e., a specific environmental characteristic. In this embodiment of the present application, the specific environmental characteristic may be a target environmental characteristic corresponding to a page obtained by the source view controller from the environment correction recorder. And setting the attribute override traitcollection attribute of the popped-up view controller as the target environment characteristic by using the source view controller, so that the configuration of the first environment variable of the page corresponding to the popped-up view controller can be realized.
Fig. 9 is a flowchart of another method for determining whether a page needs to be subjected to environment correction by a terminal according to an embodiment of the present application. As shown in fig. 9, the method includes the steps of:
in step S901, in response to the target environment characteristic being an environment variable corresponding to the bright-dark mode, a view controller or a system attribute of a view corresponding to the page is acquired.
In step S902, a system enumeration value of a bright-dark pattern in a system attribute is set to be consistent with a target environment characteristic, so as to obtain a first environment variable of a page.
In the embodiment of the present application, if the environmental characteristic to be corrected is exactly the bright-dark mode, for the page implemented by the view controller or the view, a more convenient method may be adopted to implement the determination of whether the page needs to be subjected to environmental correction. That is, when the target environment characteristic is an environment variable corresponding to a bright-dark mode, a view controller or a system attribute of a view corresponding to the page may be acquired, and then a system enumeration value of the bright-dark mode in the system attribute is set to be consistent with the target environment characteristic, so as to obtain a first environment variable of the page.
Still taking the application as an example of an application developed in the iOS system, the view controller or the view may be directly set with its system attribute, overrideiserterface, which requires a system enumeration value of the shading pattern. The enumerated values of the system are defined as follows:
public enum UIUserInterfaceStyle:Int,@unchecked Sendable{
case unspecified=0
case light=1
case dark=2
Where "case light=1" may be used to represent a bright mode and "case dark=2" may be used to represent a dark mode.
As before, the local modification method may also be used to determine if the page requires context correction. Fig. 10 is a flowchart of another method for determining whether a page needs to be subjected to environmental correction by a terminal when the page provided in the embodiment of the present application is implemented by a single view controller or a single view. As shown in fig. 10, the method includes the steps of:
in step S1001, a member variable is added to the view controller or view.
In step S1002, a module identification of a page is acquired.
In step S1003, the query result is acquired in the environmental correction recorder using the module identification.
In step S1004, in response to the query result not being null, the value of the member variable is set to true, otherwise the value of the member variable is set to false.
In step S1005, the value of the member variable is queried, and it is determined whether the page requires environmental correction based on the value of the member variable.
In this embodiment of the present application, when determining whether a page needs to be subjected to environmental correction in a local modification manner, a member variable may be first added to a view controller or a view, and a module identifier of the page may be obtained. And querying in the environment correction recorder by using the acquired module identifier, and acquiring a query result. If the query result is not null, it indicates that the registry of the environment correction recorder has records of the module, and the current page needs to be subjected to environment correction, so that the value of the member variable is set to be true, otherwise, the value of the member variable is set to be false. Further, querying the value of the member variable can determine whether the page requires environmental remediation based on the value of the member variable.
That is, the local modification method is substantially the same as that in the embodiment shown in fig. 5, except that modification is performed only for a single view controller or a single view itself, without creating a parent view controller or a parent view, and modification of a child view controller or child view is achieved by modifying the parent view controller or the parent view. In the local modification method, a specific implementation process of determining whether the page needs to be subjected to the environment correction is determined, and a specific implementation process of acquiring the first environment variable of the page from the environment correction recorder when the page needs to be subjected to the environment correction is described in the embodiments shown in fig. 5 and fig. 6, which are not described herein.
In the embodiment of the application, the resources corresponding to the environment can be managed by the resource manager, and the environment variables can be used for inquiring and acquiring the corresponding resources from the resource manager.
Fig. 11 is a flowchart of a method for obtaining a first resource corresponding to a first environment variable according to an embodiment of the present application. As shown in fig. 11, the method includes the steps of:
in step S1101, a first environment variable is input to the resource manager.
The resource manager comprises a system resource manager and a custom resource manager.
In step S1102, in response to the resource being a picture resource or a file resource, a first resource corresponding to a first environment variable is obtained from a system resource manager.
In step S1103, in response to the resource being another resource, the custom resource manager obtains a first resource corresponding to the first environment variable.
In this embodiment of the present application, when a first resource corresponding to a first environment variable is obtained, the first environment variable may be input to a resource manager, so as to query and obtain the first resource corresponding to the first environment variable from the resource manager. The resource manager comprises a system resource manager and a custom resource manager, wherein the system resource manager is used for managing picture resources and file resources, and the custom resource manager is used for managing other resources. When the resource is a picture resource or a file resource, a first resource corresponding to a first environment variable can be obtained from a system resource manager; when the resource is other resources, the user-defined resource manager can obtain a first resource corresponding to the first environment variable.
In this embodiment, the resource may include at least one of the following: preassembling resources in the terminal; resources stored in the server; the resource after processing the preassembled resource or the resource downloaded from the server; newly generated resources in the terminal. That is, in the embodiment of the present application, the sources of the resources that vary with the terminal environment are expanded as follows: downloading from a server side, reading from a pre-installed resource, processing from the pre-installed resource and generating completely. The resources downloaded from the server side refer to resources which can be downloaded from the server side. Reading from a pre-packaged resource refers to a resource that can be put into the pre-package of an application, which is a common resource acquisition mode at present. A resource further processed from the source means that the resource can be read into memory from a server or pre-packaged, and further processed by program code, including but not limited to: cutting, turning over, deforming, adding a filter, etc. The completely new generated resource refers to completely new generation of a resource in the memory according to the service requirement. For example: a color, picture, file, etc. is created with the code.
In this embodiment of the present application, after the resource is acquired, an integration process is further required. In particular, different environment variables may be created at the terminal. Taking an application as an example of an application developed in an iOS system, the environment variables are instances of the UITraitCollection class, each instance representing an environment variable, such as: taking the device direction as an example, when the device is in a normal size of the screen in the vertical direction (this case is a tablet computer with a horizontal screen and a vertical screen), the corresponding environment variables are: UIT collection (vertical SizeClass:. Regular); when the device is in a compact size with the screen in the vertical direction (this is the case for a flat screen cell phone), the corresponding environment variables are: uitraitCollection (vertical Sizeclass:. Compact). The implementation code may be, for example:
let regular=UITraitCollection(verticalSizeClass:.regular)
let compact=UITraitCollection(verticalSizeClass:.compact)
a resource manager is then created to associate the resource with the environment variable. Taking an application as an example of an application developed in an iOS system, the iOS system is provided with a system resource manager, which is an example of UIImageAsset class and NSDataAsset class. Each instance represents a resource manager that can mount a number of different variants of different environment variables corresponding to the same resource, such as: let asset=uiimageasset (), asset being a picture resource manager; let dataasset=nsdataasset (), dataAsset is a file resource manager.
In order to realize that different pictures are used in different environments in a configuration interface, the UIIMageAsset of the system needs to configure multiple sets of pictures, and the multiple sets of pictures are placed into a pre-package, so that the pre-package is overlarge and resources are occupied. In view of this, a custom resource manager can also be created.
Fig. 12 is a flowchart of a method for creating a custom resource manager according to an embodiment of the present application. As shown in fig. 12, the method includes the steps of:
in step S1201, a target custom class is created.
In step S1202, private member variables of the target custom class are created.
The private member variable is a dictionary, the keys of the dictionary are environment variables, and the values are resources corresponding to the environment variables.
In step S1203, a plurality of first public member methods are created.
The first public member method is used for realizing the addition, deletion and correction of the dictionary.
In step S1204, a second public member method is created.
The second public member method is used for detecting the current environment of the terminal and determining corresponding resources based on the detected environment.
In the embodiment of the application, the target custom class can be created first, then the private member variable of the target custom class is created, and a plurality of first public member methods and a second public member method are created, so that the creation of the custom resource manager is realized.
Still taking the application as an example of an application developed in an iOS system, when creating a custom resource manager, a custom class may be created first, named "selfDefinemanager". Then a private member variable of "selfDefinemanager" is created, which is a dictionary whose key is an environment variable and whose value is the corresponding resource. A plurality of first public member methods are then created that can prune the dictionary to facilitate external registration/de-registration of the resource to the resource manager. And finally, a second public member method is created, so that the environment of the current equipment is conveniently detected, and the corresponding resource is selected and handed to the outside for use.
After the creation of the resource manager is completed, the resource may be registered with the resource manager. In an example, when implementing resource registration by using the system resource manager, for example, a picture a that needs to be displayed in "normal size of screen in vertical direction" is registered in an asset folder, a picture B that needs to be displayed in "compact size of screen in vertical direction" is registered in an asset folder, and the implementation code may be:
asset.register(regular,with:imageA)
asset.register(compact,with:imageB)
When the custom manager is used to implement resource registration, the implementation code may be:
manager.register(regular,with:imageA)
manager.register(compact,with:imageB)
the integrated resources may be used. In the iOS system, if the resource is a picture and the control used for loading the picture in the application is UIImageView, the system can automatically find out the corresponding picture in the current environment and display the picture. If the resource is another resource, such as video, file, color, etc., then the custom environment using step is required. The environment using step comprises detecting the change of the environment where the terminal is located and selecting the resources corresponding to the current environment variables. For the UIView class of the UIViewController and the UI environment characteristic, the system enables the UIT environment interface to be realized, so that the UIT environment interface has a traitCollection attribute which represents the real environment of the current device; they also have the traitcollelectiondidchange method, which can listen for device changes.
In the embodiment of the application, the detection of the environmental change of the terminal can be realized in the custom resource manager or other custom controls in the terminal. In one example, if detection of a change in the terminal environment is implemented in a custom control, it can be implemented by a method func traitCollectionDidChange (_prevtc: UITraitCollection. In this method, the super. TraitCollectionDidCHange (prevtc) is called in a conventional manner, and then the custom logic is written, and the code may be, for example:
override func traitCollectionDidChange(_prevtc:UITraitCollection?){
super.traitCollectionDidChange(prevtc)
Custom logic
}
The custom logic is an implementation method for selecting resources corresponding to the current environment variables. Because in the resource manager, the association of the resource with the environment is completed through the resource registration, the custom logic can be realized by querying the resource corresponding to the environment variable. Specifically, the environmental variable obtained by the query can be firstly taken out, namely self. TraitCollection (because the system can automatically assign the current environmental variable to the traitCollection attribute of the control), then the image (with:) method of the system manager is called, the environmental variable is taken as a parameter to be input, and the return value of the method, namely the corresponding picture is taken. The code may be, for example:
if a system resource manager is used: imagea=asset.image (with: self traitcollection)
If a custom resource manager is used: imagea=manager image (with: self.traitcollection).
Fig. 13 is a flowchart of an application page display method according to an embodiment of the present application. Steps S1301 to S1304 in the embodiment shown in fig. 12 are substantially the same as steps S201 to S204 in the embodiment shown in fig. 2, and are not described here again. As shown in fig. 13, the method further includes the steps of:
In step S1305, in response to determining that the current page display does not need to perform environment correction, the terminal acquires a second environment variable of the page from the operating system.
The second environment variable is an environment variable corresponding to the current real environment.
In step S1306, a second resource corresponding to the second environment variable is acquired, and a page of the application is displayed using the second resource.
In this embodiment of the present application, if the terminal determines that the current page display does not need to perform environment correction, the terminal may directly obtain a second environment variable of the page from the operating system, where the second environment variable is an environment variable corresponding to the current real environment. And then, acquiring a second resource corresponding to the second environment variable, and displaying the page of the application by using the second resource.
FIG. 14 is a schematic diagram of a relationship between resources and environment-resource configuration provided by an embodiment of the present application. As shown in fig. 14, in the conventional case, when the real environment where the terminal is located changes, the real environment may be directly used to query the environment-resource configuration, so as to obtain the corresponding resource in the real environment, and then the page of the terminal is displayed using the resource. When the terminal needs to display a page different from a page corresponding to the real environment according to the service requirement, the real environment can be corrected to obtain a virtual environment, then the corresponding resource under the virtual environment is obtained, and the page of the terminal is displayed by using the resource. According to different modes of terminal page realization, the manufacturing of the environment corrector is carried out according to each mode, the manufacturing mode of each environment corrector is simplified as far as possible on the premise that a terminal operating system provides support, and the flexible adjustment of the environment-resource is carried out by means of environment correction instead of modifying the environment-resource relation.
Furthermore, according to the technical scheme of the embodiment of the application, the picture compatible with the terminal operating system and the binary file are integrated by using the system resource management, and other resources which are not supported by the terminal operating system are integrated by using the user-defined resource manager, so that the environment-resource relation is effectively established and maintained, the service requirement is met, the pre-package volume is effectively reduced, and the purpose of flexibly adjusting the displayed resources is achieved without limitation. The support of the bottom layer scheme can be realized rapidly whether the specific skin-changing service is made or the internationalization and regional customization of language, style and other services are made.
Any combination of the above optional solutions may be adopted to form an optional embodiment of the present application, which is not described herein in detail.
The following are device embodiments of the present application, which may be used to perform method embodiments of the present application. For details not disclosed in the device embodiments of the present application, please refer to the method embodiments of the present application.
Fig. 15 is a schematic diagram of an application page display device according to an embodiment of the present application. As shown in fig. 15, the application page display device includes:
the environment correction judging module 1501 is configured to, in response to receiving the page display instruction, access an environment correction recorder by the terminal, and determine whether the page needs to be subjected to environment correction, where the environment correction recorder includes a registry of all modules in an application that need to correct the real environment of the terminal, and the modules include one or more pages.
An environment variable acquisition module 1502 is configured to, in response to determining that the page requires an environment correction, acquire a first environment variable of the page from the environment correction recorder, the first environment variable being a corrected environment variable.
The resource obtaining module 1503 is configured to obtain a first resource corresponding to the first environment variable.
A display module 1504 configured to display a page of an application using a first resource.
According to the technical scheme provided by the embodiment of the application, the environment correction recorder is arranged, when the page display instruction is received, the terminal accesses the environment correction recorder, whether the current environment of the terminal needs to be corrected is judged, the first environment variable of the page is acquired from the environment correction recorder when needed, the first resource corresponding to the first environment variable is acquired, and then the page of the application is displayed by using the first resource, so that the environment variable required by the page display can be flexibly and efficiently acquired when the current environment of the terminal changes, the resource corresponding to the page display is further acquired, the preassembly of the resources of all conditions of the page display is not needed, the volume of an application preassembly resource package is reduced, the utilization efficiency of the hardware resource of the terminal is improved, the efficiency of the page display of the application in the terminal is improved, and the user experience is improved.
In the embodiment of the application, the environment correction recorder is configured in the following manner: in response to the application starting, the environment remediation recorder obtains an initial configuration file; extracting a shielding item in the initial configuration file, mapping the shielding item into a registry, wherein the registry comprises module identifications of modules needing to be subjected to environment correction and target environment characteristics, and the target environment characteristics comprise descriptions corresponding to requirements of module service requirements.
In the embodiment of the present application, the environmental correction recorder is further configured in the following manner: in response to the application receiving a configuration instruction sent by the server at run-time, updating the registry based on the configuration instruction; the registry in the environmental remediation recorder is written to the configuration file either in response to the application ending running or the application receiving a save registry command.
In this embodiment of the present application, when a page is implemented by a single view controller or a single view, the terminal determines whether the page needs to perform environmental correction, including: creating a subclass for the view controller or the view, wherein the subclass of the view controller is a base class of all view controllers in the application, and the subclass of the view is a base class of all views in the application; adding a member variable for the subclass of the view controller or the subclass of the view; acquiring a module identifier of a page; obtaining a query result in the environment correction recorder by using the module identifier; setting the value of the member variable to true in response to the query result not being null, otherwise setting the value of the member variable to false; querying the value of the member variable, and determining whether the page needs to be subjected to environment correction based on the value of the member variable.
In this embodiment of the present application, acquiring a first environment variable of a page from an environment correction recorder includes: acquiring target environmental characteristics corresponding to the page from the environmental correction recorder; newly creating environmental characteristics in the system automatic calling method when the environment of the terminal changes according to the target environmental characteristics; and assigning the newly-built environment characteristic to the environment attribute in the system automatic call method to obtain a first environment variable of the page.
In this embodiment, the page is implemented by a parent-child view controller, and acquiring, from an environment correction recorder, a first environment variable of the page includes: acquiring target environmental characteristics corresponding to the page from the environmental correction recorder by using the father view controller; and calling a system method of the parent view controller, and configuring a first environment variable of a page corresponding to the child view controller based on the target environment characteristic in the system method.
In the embodiment of the application, the page is realized by the source view controller and the popped view controller, and the page corresponding to the popped view controller and the page corresponding to the source view controller form a popping relation; acquiring a first environment variable of a page from an environment remediation recorder, comprising: acquiring target environmental characteristics corresponding to the page from the environmental correction recorder by using a source view controller; using the source view controller, configuring a first environment variable of a page corresponding to the pop-up view controller based on the target environment characteristic.
In this embodiment of the present application, acquiring a first environment variable of a page from an environment correction recorder includes: responding to the environment variable corresponding to the bright-dark mode of the target environment characteristic, and acquiring a view controller or a system attribute of the view corresponding to the page; and setting the system enumeration value of the bright-dark mode in the system attribute to be consistent with the target environment characteristic so as to obtain a first environment variable of the page.
In this embodiment of the present application, when a page is implemented by a single view controller or a single view, the terminal determines whether the page needs to perform environmental correction, including: adding a member variable for the view controller or the view; acquiring a module identifier of a page; obtaining a query result in the environment correction recorder by using the module identifier; setting the value of the member variable to true in response to the query result not being null, otherwise setting the value of the member variable to false; querying the value of the member variable, and determining whether the page needs to be subjected to environment correction based on the value of the member variable.
In this embodiment of the present application, obtaining a first resource corresponding to a first environment variable includes: inputting a first environment variable into a resource manager, wherein the resource manager comprises a system resource manager and a custom resource manager; responding to the resource as a picture resource or a file resource, and acquiring a first resource corresponding to a first environment variable from a system resource manager; and responding to the resources as other resources, and obtaining the first resources corresponding to the first environment variables by the user-defined resource manager.
In the embodiment of the application, the custom resource manager is created in the following manner: creating a target custom class; creating a private member variable of the target custom class, wherein the private member variable is a dictionary, the keys of the dictionary are environment variables, and the values are resources corresponding to the environment variables; creating a plurality of first public member methods, wherein the first public member methods are used for realizing addition, deletion and modification of the dictionary; and creating a second public member method, wherein the second public member method is used for detecting the current environment of the terminal and determining corresponding resources based on the detected environment.
In this embodiment, the resources include at least one of the following: preassembling resources in the terminal;
resources stored in the server; the resource after processing the preassembled resource or the resource downloaded from the server; newly generated resources in the terminal.
In this embodiment of the present application, further includes: in response to determining that the current page display does not need to be subjected to environment correction, the terminal obtains a second environment variable of the page from the operating system, wherein the second environment variable is an environment variable corresponding to the current real environment; acquiring a second resource corresponding to a second environment variable; and displaying the page of the application by using the second resource.
It should be understood that the sequence number of each step in the foregoing embodiment does not mean that the execution sequence of each process should be determined by the function and the internal logic of each process, and should not limit the implementation process of the embodiment of the present application in any way.
Fig. 16 is a schematic diagram of an electronic device provided in an embodiment of the present application. As shown in fig. 16, the electronic device 16 of this embodiment includes: a processor 1601, a memory 1602, and a computer program 1603 stored in the memory 1602 and executable on the processor 1601. The steps of the various method embodiments described above are implemented when the processor 1601 executes the computer program 1603. Alternatively, the processor 1601, when executing the computer program 1603, performs the functions of the modules/units of the apparatus embodiments described above.
The electronic device 16 may be a desktop computer, a notebook computer, a palm computer, a cloud server, or the like. The electronic device 16 may include, but is not limited to, a processor 1601 and a memory 1602. It will be appreciated by those skilled in the art that fig. 16 is merely an example of the electronic device 16 and is not limiting of the electronic device 16 and may include more or fewer components than shown, or different components.
The processor 1601 may be a central processing unit (Central Processing Unit, CPU), or other general purpose processor, digital signal processor (Digital Signal Processor, DSP), application specific integrated circuit (Application Specific Integrated Circuit, ASIC), field programmable gate array (Field-Programmable Gate Array, FPGA) or other programmable logic device, discrete gate or transistor logic device, discrete hardware components, or the like.
The memory 1602 may be an internal storage unit of the electronic device 16, such as a hard disk or memory of the electronic device 16. The memory 1602 may also be an external storage device of the electronic device 16, such as a plug-in hard disk, a Smart Media Card (SMC), a Secure Digital (SD) Card, a Flash memory Card (Flash Card), or the like, provided on the electronic device 16. Memory 1602 may also include both internal and external storage units of electronic device 16. The memory 1602 is used to store computer programs and other programs and data required by the electronic device.
It will be apparent to those skilled in the art that, for convenience and brevity of description, only the above-described division of the functional units and modules is illustrated, and in practical application, the above-described functional distribution may be performed by different functional units and modules according to needs, i.e. the internal structure of the apparatus is divided into different functional units or modules to perform all or part of the above-described functions. The functional units and modules in the embodiment may be integrated in one processing unit, or each unit may exist alone physically, or two or more units may be integrated in one unit, where the integrated units may be implemented in a form of hardware or a form of a software functional unit.
The integrated modules/units, if implemented in the form of software functional units and sold or used as stand-alone products, may be stored in a computer readable storage medium. Based on such understanding, the present application implements all or part of the flow in the methods of the above embodiments, or may be implemented by a computer program to instruct related hardware, and the computer program may be stored in a computer readable storage medium, where the computer program may implement the steps of the respective method embodiments described above when executed by a processor. The computer program may comprise computer program code, which may be in source code form, object code form, executable file or in some intermediate form, etc. The computer readable medium may include: any entity or device capable of carrying computer program code, a recording medium, a U disk, a removable hard disk, a magnetic disk, an optical disk, a computer Memory, a Read-Only Memory (ROM), a random access Memory (Random Access Memory, RAM), an electrical carrier signal, a telecommunications signal, a software distribution medium, and so forth.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting thereof; although the present application has been described in detail with reference to the foregoing embodiments, it should be understood by those of ordinary skill in the art that: the technical scheme described in the foregoing embodiments can be modified or some technical features thereof can be replaced by equivalents; such modifications and substitutions do not depart from the spirit and scope of the technical solutions of the embodiments of the present application, and are intended to be included in the scope of the present application.

Claims (16)

1. An application page display method, wherein the method is executed by a terminal, and the method comprises:
in response to receiving a page display instruction, the terminal accesses an environment correction recorder to determine whether the page needs to be subjected to environment correction, wherein the environment correction recorder comprises a registry of all modules in the application, which need to correct the real environment of the terminal, and the modules comprise one or more pages;
in response to determining that the page requires environmental remediation, obtaining a first environmental variable of the page from the environmental remediation recorder, the first environmental variable being a remedied environmental variable;
acquiring a first resource corresponding to the first environment variable;
and displaying the page of the application by using the first resource.
2. The method of claim 1, wherein the environmental remediation recorder is configured in the following manner:
in response to the application launch, the environmental remediation recorder obtains an initial configuration file;
and extracting a shielding item in the initial configuration file, and mapping the shielding item into a registry, wherein the registry comprises a module identifier of a module needing to be subjected to environment correction and target environment characteristics, and the target environment characteristics comprise descriptions corresponding to the needs of the module business needs.
3. The method of claim 2, wherein the environmental remediation recorder is further configured in the following manner:
in response to the application receiving a configuration instruction sent by a server during running, updating the registry based on the configuration instruction; or alternatively
And writing a registry in the environment correction recorder into the configuration file in response to the application ending running or the application receiving a command to save the registry.
4. A method according to claim 2 or 3, wherein when the page is implemented by a single view controller or a single view, the terminal determines whether the page requires environmental remediation, comprising:
creating a subclass for the view controller or the view, wherein the subclass of the view controller is a base class of all view controllers in the application, and the subclass of the view is a base class of all views in the application;
adding a member variable for the subclass of the view controller or the subclass of the view;
acquiring a module identifier of the page;
obtaining a query result in the environmental remediation recorder using the module identifier;
setting the value of the member variable to true in response to the query result not being null, otherwise setting the value of the member variable to false;
And inquiring the value of the member variable, and determining whether the page needs to be subjected to environment correction or not based on the value of the member variable.
5. The method of claim 4, wherein the obtaining the first environment variable of the page from the environment remediation recorder comprises:
acquiring target environmental characteristics corresponding to the page from the environmental correction recorder;
newly creating environment characteristics in a system automatic calling method when the environment of the terminal changes according to the target environment characteristics;
and assigning the newly-built environment characteristic to the environment attribute in the system automatic call method to obtain a first environment variable of the page.
6. A method according to claim 2 or 3, wherein the page is implemented by a parent-child view controller, the obtaining the first environment variable of the page from the environment remediation recorder comprising:
acquiring target environmental characteristics corresponding to the page from the environmental correction recorder by using a father view controller;
and calling a system method of the father view controller, and configuring a first environment variable of a page corresponding to the child view controller based on the target environment characteristic in the system method.
7. A method according to claim 2 or 3, wherein the pages are implemented by a source view controller and a popped view controller, the page corresponding to the popped view controller and the page corresponding to the source view controller forming a pop-up relationship;
the obtaining the first environment variable of the page from the environment correction recorder includes:
acquiring target environmental characteristics corresponding to the page from the environmental correction recorder by using a source view controller;
and using the source view controller to configure a first environment variable of a page corresponding to the popped view controller based on the target environment characteristic.
8. A method according to claim 2 or 3, wherein said obtaining a first environment variable of the page from the environment remediation recorder comprises:
responding to the environment variable corresponding to the light and dark mode of the target environment characteristic, and acquiring a view controller or a system attribute of a view corresponding to the page;
and setting the system enumeration value of the bright-dark mode in the system attribute to be consistent with the target environment characteristic so as to obtain a first environment variable of the page.
9. A method according to claim 2 or 3, wherein when the page is implemented by a single view controller or a single view, the terminal determines whether the page requires environmental remediation, comprising:
Adding a member variable to the view controller or view;
acquiring a module identifier of the page;
obtaining a query result in the environmental remediation recorder using the module identifier;
setting the value of the member variable to true in response to the query result not being null, otherwise setting the value of the member variable to false;
and inquiring the value of the member variable, and determining whether the page needs to be subjected to environment correction or not based on the value of the member variable.
10. The method of claim 1, wherein the obtaining the first resource corresponding to the first environment variable comprises:
inputting the first environment variable into a resource manager, wherein the resource manager comprises a system resource manager and a custom resource manager;
responding to the resource as a picture resource or a file resource, and obtaining a first resource corresponding to the first environment variable from the system resource manager;
and responding to the resource as other resources, and obtaining a first resource corresponding to the first environment variable from the custom resource manager.
11. The method of claim 10, wherein the custom resource manager is created by:
Creating a target custom class;
creating a private member variable of the target custom class, wherein the private member variable is a dictionary, keys of the dictionary are environment variables, and values are resources corresponding to the environment variables;
creating a plurality of first public member methods, wherein the first public member methods are used for realizing addition, deletion and correction of the dictionary;
and creating a second public member method, wherein the second public member method is used for detecting the current environment of the terminal and determining corresponding resources based on the detected environment.
12. The method according to claim 10 or 11, wherein the resources comprise at least one of:
preassembling resources in the terminal;
resources stored in the server;
the resource after processing the preassembled resource or the resource downloaded from the server;
newly generated resources in the terminal.
13. The method according to claim 1, wherein the method further comprises:
in response to determining that the current page display does not need to be subjected to environment correction, the terminal acquires a second environment variable of the page from an operating system, wherein the second environment variable is an environment variable corresponding to the current real environment;
Acquiring a second resource corresponding to the second environment variable;
and displaying the page of the application by using the second resource.
14. An application page display device, comprising:
the environment correction judging module is configured to respond to receiving a page display instruction, the terminal accesses an environment correction recorder, and whether the page needs to be subjected to environment correction or not is determined, wherein the environment correction recorder comprises a registry of all modules which need to be subjected to real environment correction of the terminal in the application, and the modules comprise one or more pages;
an environment variable obtaining module configured to obtain a first environment variable of the page from the environment correction recorder in response to determining that the page requires environment correction, the first environment variable being a corrected environment variable;
the resource acquisition module is configured to acquire a first resource corresponding to the first environment variable;
and the display module is configured to display the page of the application by using the first resource.
15. An electronic device comprising a memory, a processor and a computer program stored in the memory and executable on the processor, characterized in that the processor implements the steps of the method according to any one of claims 1 to 13 when the computer program is executed.
16. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the steps of the method according to any one of claims 1 to 13.
CN202311665742.1A 2023-12-06 2023-12-06 Application page display method and device, electronic equipment and storage medium Pending CN117873613A (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202311665742.1A CN117873613A (en) 2023-12-06 2023-12-06 Application page display method and device, electronic equipment and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202311665742.1A CN117873613A (en) 2023-12-06 2023-12-06 Application page display method and device, electronic equipment and storage medium

Publications (1)

Publication Number Publication Date
CN117873613A true CN117873613A (en) 2024-04-12

Family

ID=90590836

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202311665742.1A Pending CN117873613A (en) 2023-12-06 2023-12-06 Application page display method and device, electronic equipment and storage medium

Country Status (1)

Country Link
CN (1) CN117873613A (en)

Similar Documents

Publication Publication Date Title
CN109597814B (en) Online rapid delivery system of background management information system
US20190220332A1 (en) Application processing method and apparatus
CN102520987B (en) Online experience and installation method, device, server and management system of application program
US8572033B2 (en) Computing environment configuration
CN104951326B (en) Webpage access method and device
CN101395572B (en) Auxiliary display gadget for distributed content
US8479108B2 (en) Methods and systems for shareable virtual devices
CN109408136B (en) Information processing method, information processing apparatus, storage medium, and electronic device
CN110049456B (en) Method and device for displaying rich media on mobile terminal and mobile terminal
CN110990075B (en) Method, device, equipment and storage medium for starting fast application
US20090248737A1 (en) Computing environment representation
US10169017B2 (en) Crowdsourcing location based applications and structured data for location based applications
EP3417639A1 (en) Message extension app store
CN109271211B (en) Method, device, equipment and medium for separating application program
US20140053074A1 (en) Method and apparatus for generating and utilizing a cloud service-based content shortcut object
CN114185491B (en) Partition file downloading method and device, storage medium and computer equipment
US20150381714A1 (en) Application registration and interaction
CN103577522A (en) Method for managing data and an electronic device thereof
CN114385164A (en) Page generation and rendering method and device, electronic equipment and storage medium
CN111857531A (en) Mobile terminal and file display method thereof
CN114915618B (en) Upgrade package downloading method and device
CN111443903A (en) Software development file acquisition method and device, electronic equipment and storage medium
CN110457408B (en) Personalized map downloading method, device, equipment and storage medium
CN103309677A (en) Built-in resource management method, device and terminal
CN117873613A (en) Application page display method and device, electronic equipment and storage medium

Legal Events

Date Code Title Description
PB01 Publication
PB01 Publication
SE01 Entry into force of request for substantive examination
SE01 Entry into force of request for substantive examination