[go: up one dir, main page]

CN116974678B - Page-based view controller jump method, device and storage medium - Google Patents

Page-based view controller jump method, device and storage medium Download PDF

Info

Publication number
CN116974678B
CN116974678B CN202310961007.9A CN202310961007A CN116974678B CN 116974678 B CN116974678 B CN 116974678B CN 202310961007 A CN202310961007 A CN 202310961007A CN 116974678 B CN116974678 B CN 116974678B
Authority
CN
China
Prior art keywords
animation
jump
view controller
view
controller
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.)
Active
Application number
CN202310961007.9A
Other languages
Chinese (zh)
Other versions
CN116974678A (en
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 Selis Phoenix Intelligent Innovation Technology Co ltd
Original Assignee
Chongqing Selis Phoenix Intelligent Innovation Technology 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 Selis Phoenix Intelligent Innovation Technology Co ltd filed Critical Chongqing Selis Phoenix Intelligent Innovation Technology Co ltd
Priority to CN202310961007.9A priority Critical patent/CN116974678B/en
Publication of CN116974678A publication Critical patent/CN116974678A/en
Application granted granted Critical
Publication of CN116974678B publication Critical patent/CN116974678B/en
Active legal-status Critical Current
Anticipated expiration legal-status Critical

Links

Classifications

    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F9/00Arrangements for program control, e.g. control units
    • G06F9/06Arrangements for program control, e.g. control units using stored programs, i.e. using an internal store of processing equipment to receive or retain programs
    • G06F9/44Arrangements for executing specific programs
    • G06F9/451Execution arrangements for user interfaces
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0481Interaction techniques based on graphical user interfaces [GUI] based on specific properties of the displayed interaction object or a metaphor-based environment, e.g. interaction with desktop elements like windows or icons, or assisted by a cursor's changing behaviour or appearance
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/0485Scrolling or panning
    • GPHYSICS
    • G06COMPUTING OR CALCULATING; COUNTING
    • G06FELECTRIC DIGITAL DATA PROCESSING
    • G06F3/00Input arrangements for transferring data to be processed into a form capable of being handled by the computer; Output arrangements for transferring data from processing unit to output unit, e.g. interface arrangements
    • G06F3/01Input arrangements or combined input and output arrangements for interaction between user and computer
    • G06F3/048Interaction techniques based on graphical user interfaces [GUI]
    • G06F3/0484Interaction techniques based on graphical user interfaces [GUI] for the control of specific functions or operations, e.g. selecting or manipulating an object, an image or a displayed text element, setting a parameter value or selecting a range
    • G06F3/0486Drag-and-drop

Landscapes

  • Engineering & Computer Science (AREA)
  • Theoretical Computer Science (AREA)
  • General Engineering & Computer Science (AREA)
  • Human Computer Interaction (AREA)
  • Physics & Mathematics (AREA)
  • General Physics & Mathematics (AREA)
  • Software Systems (AREA)
  • Processing Or Creating Images (AREA)

Abstract

The application provides a page-based view controller skipping method, a page-based view controller skipping device and a storage medium. The method comprises the following steps: responding to clicking operation of a user on a function control in a page of an application program, and popping up a child view controller corresponding to the function control by utilizing a father view controller; inquiring a dictionary of the application program to obtain configuration information corresponding to the sub-view controller; and calling a jump function corresponding to a preset jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of the proxy object of the parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump. The application realizes the separation of data and views, improves the fluency and the responsiveness of the user interface, and reduces the complex relationship between views so as to optimize the use of the memory.

Description

Page-based view controller jump method, device and storage medium
Technical Field
The present application relates to the field of computer technologies, and in particular, to a page-based method, apparatus, and storage medium for skipping a view controller.
Background
In existing mobile operating systems (such as iOS operating systems), common user interface designs include opening a new view over the current view to provide additional functionality. These new views may partially or fully overlay the current view, have different transparency, and sometimes have animation effects. Common scenarios are, for example, a user clicking a button to open a date selector, or sliding a bar to switch advertisements. After the operation is completed, the new view disappears and the original view is redisplayed.
Currently, the prior art implementations are mainly two kinds of implementations. One is when a user activates a function, a view is created and added to the current window or view. The other is to create the view at the time of original page creation, but default to not be visible until the user activates a certain function. However, both of these methods have some problems.
First, both of these approaches focus the data logic and view presentation in the same view (i.e., view), which does not conform to the fine programming style of data and view separation, which is detrimental to code reading and post-maintenance. Secondly, because the view must be added to the current page, a complex parent-child relationship is formed, which is prone to errors and confusion. For example, if there are views with the same tag label in both the original page and the new view, then when looking for a view of a particular tag, an erroneous view may be returned and further operations may cause the application to crash. Finally, if a pre-created view is selected and set to invisible, this view will always be present in memory even though it may only be used when the user activates a certain function, which is unnecessary for consumption of system memory.
Disclosure of Invention
In view of the above, the embodiments of the present application provide a method, an apparatus, and a storage medium for skipping a view controller based on a page, so as to solve the problems in the prior art that data and views cannot be separated, smoothness and responsiveness of a user interface are reduced, a view hierarchy relationship is complex, and memory consumption of a system is increased.
In a first aspect of an embodiment of the present application, a method for skipping a view controller based on a page is provided, including: responding to clicking operation of a user on a function control in a page of an application program, and popping up a child view controller corresponding to the function control by utilizing a father view controller; inquiring a dictionary of an application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a skip mode and skip execution logic; and calling a jump function corresponding to a preset jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of the proxy object of the parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump.
In a second aspect of an embodiment of the present application, there is provided a page-based view controller jumping apparatus, including: the response module is configured to respond to clicking operation of a user on the function control in the page of the application program, and pop up the child view controller corresponding to the function control by utilizing the parent view controller; the query module is configured to query a dictionary of the application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a skip mode and skip execution logic; the calling module is configured to call a jump function corresponding to a preset jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of a proxy object of the parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump.
In a third 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.
The above at least one technical scheme adopted by the embodiment of the application can achieve the following beneficial effects:
Popping up child view controllers corresponding to the function controls by using the parent view controller in response to clicking operation of the user on the function controls in the page of the application program; inquiring a dictionary of an application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a skip mode and skip execution logic; and calling a jump function corresponding to a preset jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of the proxy object of the parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump. The application realizes the separation of data and views, improves the fluency and the responsiveness of the user interface, and reduces the complex relationship between views so as to optimize the use of the memory.
Drawings
In order to more clearly illustrate the technical solutions of the embodiments of the present application, the drawings used in the embodiments or the description of the prior art will be briefly described below, and it is obvious that the drawings in the following description are only some embodiments of the present application, and other drawings may be obtained according to these drawings without inventive effort for a person skilled in the art.
FIG. 1 is a schematic flow diagram of a method for skipping a page-based view controller according to an embodiment of the present application;
FIG. 2 is a schematic diagram of a dictionary created in a real scenario in accordance with an embodiment of the present application;
FIG. 3 is a schematic diagram of the structure of a parent-child view controller hierarchy constructed in a real scene according to an embodiment of the present application;
FIG. 4 is a schematic diagram of a structure of a page-based view controller jump device according to an embodiment of the present application;
fig. 5 is a schematic structural diagram of an electronic device according to an embodiment of the present application.
Detailed Description
Embodiments of the present application will be described in more detail below with reference to the accompanying drawings. While the application is susceptible of embodiment in the drawings, it is to be understood that the application may be embodied in various forms and should not be construed as limited to the embodiments set forth herein, but rather are provided to provide a more thorough and complete understanding of the application. It should be understood that the drawings and embodiments of the application are for illustration purposes only and are not intended to limit the scope of the present application.
In the development of iOS applications, one common way of user interface interaction is to present a new view on the current page by user action, which may have an animation effect. The new view may partially or completely cover the content of the original page, and the presentation mode may be replacement or cover:
In the replacement mode, the new view completely replaces the content of the original page, and the original page temporarily disappears. If the new view is transparent or semi-transparent, the user cannot see the original page.
In the overlay mode, the new view does not replace the original page content, but is overlaid on top of the original page. If the new view is transparent or semi-transparent, the user can still see part of the original page.
When the user completes the operation, the new view will disappear (there may be an animation effect), and the original page is redisplayed. For example, a user clicking a button opens a date selector and a semi-transparent view pops up, and the date selection list is presented in a sliding list in an opaque area. Or the user slides the advertisement area, and different advertisements are switched in an animation mode. When the new view completes the task, the user can close the new view through common gestures, and the original page is redisplayed.
At present, the implementation manner of the prior art mainly comprises the following two types:
One is to create a view (a subclass of UIView, simply referred to as view) when the user clicks on a function control, and add the view to the current window or current view. When the view has completed its task, it is removed from the current page.
Another is to create a view at an earlier stage (e.g., when the original page is created) and add it to the current page, but set its visibility to invisible. When the user clicks a certain function control, the visibility of the view is set to be visible. When the view has completed its task, its visibility is set to invisible.
However, both of these implementations suffer from the following disadvantages:
1) In both implementations, view is the only container in which both data logic and view presentation are handled. This implementation does not conform to the fine programming style in which the data logic and view presentation should be separated from each other, creating inconvenience to the reading and post-maintenance of the code.
2) In the process of adding views to the current page, there is a complex parent-child relationship with the view of the current page, which may lead to hierarchical confusion and bug. For example: the original page has a View with a tag of 123, and the new View also has exactly a View with a tag of 123, and when the View with a tag of 123 is acquired, an error result may be returned, and if the method call is continued, the application program may crash because the View does not implement the related attribute or method.
3) If a view is chosen to be created in advance and its visibility set, then consumption of system resources (e.g., memory) that would always be present in memory can be a problem, particularly if such consumption is not necessary in many cases. In other words, while the view is not visible, memory resources are still occupied and may have an impact on the performance of the device.
It follows that while the prior art implements dynamic appearance and disappearance of new views, and interaction between new views and the original page, these implementations have certain problems. Whether programming style issues, such as coupling of data logic and view presentation, operational complexity issues, such as view level complexity, or resource consumption issues, such as unnecessary memory usage, present challenges to developers in implementing such common functionality. Therefore, a new solution is needed to improve the implementation of such common functions, improve code quality, reduce operational complexity, and save resource consumption.
In view of the problems existing in the prior art, the technical scheme of the application designs a view controller jump scheme, and the core idea is to use a view controller to replace the traditional view processing, so that the separation of data logic and view interface display is realized, and the design principle of MVC (model-view-controller) is more met. The design can not only improve the readability and maintainability of codes, but also avoid bug caused by complex view level relation. In addition, the technical scheme of the application uniformly manages the animation when the view appears and ends and the sub-view which can be reused by creating the manager, so that the style of the App can be better unified and the reusability of codes can be improved. This approach can also cover all sub-view situations, including situations where the user needs to intervene, such as a user dragging a button that moves with the user's finger, or a user sliding a screen-switch advertisement like a page flip, etc. Therefore, the technical scheme of the application realizes the optimization of the video controller, improves the code quality, reduces the potential bug risk, better utilizes the system resources and improves the user experience.
It should be understood that the various steps recited in the method embodiments of the present application may be performed in a different order and/or performed in parallel. Furthermore, method embodiments may include additional steps and/or omit performing the illustrated steps. The scope of the application is not limited in this respect.
The term "including" and variations thereof as used herein are intended to be open-ended, i.e., including, but not limited to. The term "based on" is based at least in part on. The term "one embodiment" means "at least one embodiment"; the term "another embodiment" means "at least one additional embodiment"; the term "some embodiments" means "at least some embodiments. Related definitions of other terms will be given in the description below. It should be noted that the terms "first," "second," and the like herein are merely used for distinguishing between different devices, modules, or units and not for limiting the order or interdependence of the functions performed by such devices, modules, or units.
It should be noted that references to "one", "a plurality" and "a plurality" in this disclosure are intended to be illustrative rather than limiting, and those skilled in the art will appreciate that "one or more" is intended to be construed as "one or more" unless the context clearly indicates otherwise.
A method and apparatus for skipping a view controller based on a page according to embodiments of the present application will be described in detail with reference to the accompanying drawings.
Fig. 1 is a schematic flow chart of a page-based view controller jump method according to an embodiment of the present application. The page-based view controller jump method of fig. 1 may be performed by an application program. As shown in fig. 1, the method for skipping the view controller based on the page specifically may include:
s101, responding to clicking operation of a user on a function control in a page of an application program, and popping up a child view controller corresponding to the function control by using a parent view controller;
S102, inquiring a dictionary of an application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a skip mode and skip execution logic;
S103, calling a jump function corresponding to a preset jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of a proxy object of the parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump.
View (View): a view generally refers to a rectangular area on a screen that may contain various user interface elements, such as buttons, pictures, etc. The size of which may be less than or equal to the screen size. For ease of understanding, in the present application, a view having a size equal to a screen is referred to as a "page", and a view having a size smaller than the screen is referred to as a "view".
Page (Page): a page is a special view whose size is equal to the screen size, i.e. the area covering the whole screen.
View Controller (View Controller): the view controller is a tool provided by the iOS system to manage views. One view controller may manage multiple views. In addition, the view controller may write code related to execution logic, data processing, and the like.
In some embodiments, prior to querying the dictionary of the application, the method further comprises: creating a dictionary in a memory when an application program is started, wherein the dictionary comprises a plurality of key value pairs, and each key value pair is used for representing configuration information corresponding to one sub-view controller in a page; wherein the keys in the key-value pair are used to identify the parent view by a globally unique string and the values in the key-value pair are used to store configuration information.
Specifically, the embodiment of the application firstly constructs a data structure, for example, a dictionary of a resident memory is created when a program is started, the dictionary stores configuration information of all sub-view controllers corresponding to all pages of the program, and thus, in the actual view switching process, all necessary information can be obtained only by querying the dictionary, and corresponding operation is executed. Specific implementation procedures for constructing a data structure are described below with reference to specific embodiments and drawings. As shown in fig. 2, fig. 2 is a schematic structural diagram of creating a dictionary in a real scene according to an embodiment of the present application. The dictionary may specifically include the following:
first, the application creates a dictionary of resident memory at startup. The dictionary is composed of a plurality of key-value pairs, each representing configuration information of a child view controller of a page. The key is used to identify the parent page, which may be a globally unique string or a reference to the view controller of the page. The value is a composite data structure that contains a plurality of elements, and configuration information contained by the value is described below:
a. Reference to child view controller: the reference points to a view controller that contains the child view and logic and data management code associated therewith.
B. animation: the predefined view shows up an animation and the view ends an animation.
C. the jump mode is as follows: common view controller hopping modes include push (push), switch (tabbar), pop (pop), custom, etc., and which mode is selected depends on the service requirements. If not specifically specified, custom means are used by default.
D. Jump specific implementation logic: different execution logic is corresponding to the selected jump mode.
Based on the above constructed data structure, when the application program runs, if the user selects a certain function control on a certain page, a certain view controller wants to pop up a certain sub-view, the program will query the dictionary to obtain the reference of the corresponding sub-view controller, the view appearance animation, the view ending animation, the jump mode and the jump concrete execution step (i.e. jump concrete implementation logic), and then perform the actual jump operation.
According to the technical scheme provided by the embodiment of the application, the configuration information of the sub-views is preset and stored, so that the program does not need to frequently create and destroy the view controller in actual operation, thereby saving system resources, simplifying the realization process of view switching and improving the readability and maintainability of codes.
Further, after the construction of the data structure is completed, the embodiment of the present application will perform the actual jump step. In an embodiment of the Present application, four ways of jumping of view controllers are provided, including four ways of Push and Pop, switch, pop and close (Present and Di smiss), and Custom. The jump mode of the four view controllers is briefly described below:
1. Push and Pop? Push and Pop): in this jump approach, a new view controller will be pushed (Push) into the stack maintained by the parent view controller, a process that is typically accompanied by default animation effects and overlay effects. When it is desired to revert to the previous view controller, the current view controller will be popped (Pop) from the stack maintained by the parent view controller. In practical applications, these default animation effects may be modified.
2. Switch (Switch): in this jump mode, the current view controller will be replaced by a new view controller. The switching operation itself has no default animation effect, but the present solution can add an animation effect. It uses a covering effect.
3. Pop-up and close (Present and Dismiss): in this jump mode, the new view controller will appear (Present) as a modal window over the current view controller. This process is typically accompanied by default animation effects and overlay effects. When the modality window needs to be closed, a closing (Dismiss) operation is performed. These default animation effects and overlay effects may be modified.
4. Custom (Custom): in this jump approach, both animation effects and overlay effects can be customized. Specific implementations will be designed and programmed according to specific needs.
In practice, all the jump steps described above should be encapsulated in a resident memory manager. When a jump operation of the view controller is required, this manager will be called by the system to perform a specific jump step. Such a design aims to simplify the complexity of the view controller jump operation and to improve the running efficiency of the program.
The implementation process and principle of the jump mode of the four view controllers will be described in detail below with reference to specific embodiments.
In some embodiments, when the jump mode is a push and pop jump mode, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises: setting a proxy object of the navigation bar controller, wherein the proxy object is used for returning a first animation management instance, the first animation management instance is used for realizing a view controller jump interface, the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method, and the navigation bar controller is used for representing a father view controller actually managed to be put into a stack.
Specifically, some necessary setting operations are required before executing the jump function. This includes setting a proxy object for the navigation bar controller, which is responsible for returning to the first animation management instance. The first animation management instance is used for realizing a jump interface of the view controller, and the interface defines an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method. The navigation bar controller is a parent view controller that actually manages the outgoing stacks.
Further, stacking refers to placing a new view controller on top of a navigation controller stack, such that the new view is displayed on the screen, covering the original view. And the pop-up is to remove one view controller from the stack top of the navigation controller and display the next view controller. By default, the new view will slide in from right to left and cover the original view.
If the default push animation of the system does not meet the requirements, the push animation can be customized. The specific steps include cancelling the default animation, setting the proxy of the navigation controller, and returning an animation management instance through the proxy, which instance needs to implement the UIViewControllerAnimatedTransitioning interface provided by the iOS system. This interface defines a series of methods of duration of the animation, instance of the animation, start of the animation, and operation after the animation ends.
In one example, the present application provides the following specific steps to implement the jump mode of push and pop:
Firstly, it is required to determine whether a navigation bar exists at the top of the current page and whether the sub-view display mode is replaced. If so, the jump can be made using a push mode. In this way, the push function provided by the iOS system is called, so that the new view completely covers the original page and the original page disappears. It should be noted that this approach to jumping is applicable to cases where the child view replaces the original page entirely, and where there is a navigation bar at the top of the original page (the navigation bar may be hidden from visual effects according to business requirements, but the actual hierarchical relationship also exists) and the original page is managed by the parent navigation bar controller.
Further, if the system default push animation does not meet the requirements, a custom push animation may be created. This requires first entering false in the second parameter of the push function, indicating that no default animation is required. Then, the proxy of the navigation bar controller (the parent controller actually managing the outgoing stack) needs to be set as an object a, and the proxy object a is a delete attribute, and the proxy object a needs to implement the following proxy method:
-(nullable id<UIViewControllerAnimatedTransitioning>)navigationContr oller:(UINavigationController*)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController*)fromVC
toViewController:(UIViewController*)toVC
The proxy method returns an object B (i.e., the first animation management instance). Object B is a custom animation management instance, and four methods defined by UIViewControllerAnimatedTransitioning interfaces (i.e., view controller jump interfaces) are needed to be implemented, i.e., the interfaces define four functions in the animation management process.
In one example, object B implements the following four methods of interface definition:
1. The animation duration returning method comprises the following steps: transitionDuration (using:)
This is an animation duration function whose return value is the total duration of the animation.
2. The animation instance return method comprises the following steps: interruptibleAnimator (using:)
This is a function of returning an animation instance, whose return value is the animation instance. The execution of the animation requires an initial state and a final state, namely: where the view of the view controller of the original page is, where the initial position of the view of the sub-view controller to appear is, where the view of the view controller of the original page is to be, and where the view of the sub-view controller is to be. The animation instance obtains the information from the parameters of the function, can modify the positions by itself, and can customize various complex animations, such as: zoom in, zoom out, page turn, rotate, combinations thereof, and the like.
3. Starting an animation processing method: animateTransition (using:)
This is the function that starts the animation, where the start function of the animation instance is called, starting the animation.
4. The animation end processing method comprises the following steps: animationEnded (_:)
This is a function called after the animation is finished, and related work such as releasing the animation instance after the animation is finished is processed inside.
It should be noted that, the above four methods are called by the iOS system at a proper time, and the embodiment of the present application is only responsible for writing service logic therein.
Next, an animation instance needs to be created. According to different business requirements, different sub-view jumps correspond to different animation instances. These animation instances can be structured in advance and stored in a global list of the system, with references placed in a dictionary, so that the animation instances can be reused, avoiding repeated code and creating multiple identical instances.
Further, in order to enable the actual stacking or stacking-off action to occur, the embodiment of the application calls the stacking function or the stacking-off function of the iOS system, and the sub-view controller is taken as a first parameter to be input, and a second parameter of the function is a boolean value, which means whether a default animation is needed.
In practical application, the animation (i.e. pop-up) when the child view disappears is actually an inverse sequence process of pushing the child view into the stack, and the system still calls the four proxy functions, namely a function tr ansitionDuration (using:) for setting the animation duration, a function interruptibleAnimator (using:) for returning to an animation instance, a function animateTransition (using:) for starting the animation, and a function animationEnded (using:) for executing the operation after the animation is finished. In interruptibleAnimator (using:) functions, the view controllers corresponding to the initial state and the final state of the animation execution are reversed, so that only the parameters of the initial state and the final state are judged, and the animation when disappeared is constructed. This disappearing animation is also put into the global list of the system, placing the references into the dictionary.
Through the steps, the embodiment of the application can realize a push-in and push-out jump mode with a self-defined animation effect, so that the jump of the view is more vivid and personalized, and the reusability and maintainability of codes are improved.
In some embodiments, when the jump mode is a switched jump mode, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises: setting a proxy object of the partition controller, wherein the proxy object is used for returning a second animation management instance, the second animation management instance is used for realizing a view controller jump interface, the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method, and the partition controller is used for representing a father view controller actually managing switching.
Specifically, when the jump mode of the view controller adopts the switching jump mode, the embodiment of the application needs to perform some preset operations first, including setting the proxy object of the partition controller, where the proxy object is used to return to the second animation management instance. The second animation management instance is used to implement a view controller jump interface defining an animation duration return method, an animation instance return method, a start animation processing method, and an animation end processing method. The partition column controller is responsible for managing the parent view controller of the switch.
In one example, the application provides a jump way to implement a handover by the following specific steps:
Firstly, it is required to determine whether there is a partition column (tabbar) at the bottom of the original page and whether the sub-view is displayed in a replaced manner. If the condition is met, the jump may be performed in a switching manner. In this case, the switching function provided by the iOS system is called, so that the original page is completely replaced by the new view, and the original page disappears. At this time, there is no animation effect. The jump mode of the switching also has some limitations of usage scenarios, for example, the jump mode of the switching is not suitable for the situation that the sub-view is partially displayed on the page, only suitable for the situation that the sub-view completely covers the original page, and the original page has a partition (although hidden from visual effect, actually still exists) at the bottom and is managed by the partition controller.
Second, if a custom switch animation needs to be constructed, namely a view appearance animation and a view disappearance animation. The proxy of the partition controller (the parent controller actually managing the outgoing stack) needs to be set as a proxy object C, which is a delete attribute, and the following proxy method needs to be implemented by the proxy object C:
-(nullable id<UIViewControllerAnimatedTransitioning>)navigationContr oller:(UINavigationController*)navigationController
animationControllerForOperation:(UINavigationControllerOperation)operation
fromViewController:(UIViewController*)fromVC
toViewController:(UIViewController*)toVC
The proxy method returns an object D (i.e., a second animation management instance), which is a user-defined animation management instance. Object D needs to implement four methods defined by the UIViewControllerAnim atedTransitioning interface (i.e., view controller jump interface) provided by the iOS system, i.e., the interface defines four functions in the animation management process.
In one example, object D implements the following four methods of interface definition:
1. The animation duration returning method comprises the following steps: transitionDuration (using:)
This is a function of the set animation duration, the return value of which is the total duration of the animation.
2. The animation instance return method comprises the following steps: interruptibleAnimator (using:)
This is a function of returning an animation instance, whose return value is the animation instance. The execution of the animation requires an initial state and a final state, namely: where the view of the view controller of the original page is, where the initial position of the view of the sub-view controller to appear is, where the view of the view controller of the original page is to be, and where the view of the sub-view controller is to be. The animation instance obtains the information from the parameters of the function, can modify the positions by itself, and can customize various complex animations, such as: zoom in, zoom out, page turn, rotate, combinations thereof, and the like.
3. Starting an animation processing method: animateTransition (using:)
This is the function that starts the animation, where the start function of the animation instance is called, starting the animation.
4. The animation end processing method comprises the following steps: animationEnded (_:)
This is a function called after the animation is finished, and related work such as releasing the animation instance after the animation is finished is processed inside.
It should be noted that, the above four methods are called by the iOS system at a proper time, and the embodiment of the present application is only responsible for writing service logic therein.
Finally, an animation instance needs to be created. An animation instance is created for each view controller's switching according to business requirements. This animation instance needs to be created and deposited in the system global list, placing its references in the dictionary so that it can be reused if needed, avoiding repetition of code and creation of multiple identical instances.
Through the steps, the embodiment of the application can realize a switching jump mode with a self-defined animation effect, thereby creating a more dynamic and attractive view switching effect and improving the reusability and maintainability of codes.
Further, in order to enable the actual switching action to occur, the embodiment of the present application sets "select attribute selectedIndex of its child view controller" to the child view controller that wants to switch to "for the view controller corresponding to the division bar.
In some embodiments, when the jump mode is a pop-up and close jump mode, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises: setting a proxy object of the sub-view controller, wherein the proxy object is used for returning a third animation management instance, and the third animation management instance is used for representing interactive and non-interactive animation management instances when popping up and closing; the third animation management instance is used for realizing a view controller jump interface, wherein the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method.
Specifically, the embodiment of the application also provides an operation flow and steps when the jump mode is the pop-up and closing jump mode. First, before the jump function triggering system executes the method of the proxy object of the father view controller, the proxy object of the child view controller is set, and the proxy object is used for returning to a third animation management instance, wherein the third animation management instance is used for representing interactive and non-interactive animation management instances when popping up and closing.
In one example, the steps of the jump mode of implementing the pop-up and the close according to the embodiment of the present application are as follows:
First, the jump mode is determined to be pop-up and off. Pop is a way of switching between view controllers provided by iOS systems that is more flexible than push. The usage scenario of the pop-up and close jump approach includes the following constraints:
The popup does not require the parent navigation bar controller to be arranged on the original page controller; more default animations provided by the system can be selected (modalTransition style) in a popping way, and the animations can be customized; popping up more sub-view presentation mode selections (presentation style), wherein the sub-view can be completely covered on the original page, partially covered on the original page, or completely replaced by the original page; it should be noted that: the method is not provided with a push-in and push-out jump mode and a switching jump mode, the push-in and push-out jump mode and the switching jump mode can only be completely covered, and the sub-view presentation mode can be customized.
And secondly, constructing a custom pop-up and closing animation. Several default animations carried by the system are popped up for selection, and if the animation modes do not meet the service requirements, the animation modes need to be customized; the specific operation is as follows: the second parameter in the pop-up method is entered into the false meaning that no default animation is required. Then, the proxy of the parent view controller (the controller that actually manages popup) is set as a proxy object X for returning the animation management instance that cannot be interacted with and the animation management instance that can be interacted with, and the proxy object X is transitioningDelegate attribute. Proxy object X needs to implement the UIVie wControllerTransitioningDelegate interface (i.e., view controller hop interface) provided by the iOS system and implement the following four methods defined by the interface:
returning to the animation management instance B which cannot be interacted when popping up: animationController (forPresente d: presenting: source:);
Interactive animation management instance C when popup is returned: interactionControllerForPresenta tion (using:);
returning to the animation management instance D which can not be interacted when being closed: animationController (forDismissed:);
Returning to the interactive animation management instance E when closed: interactionControllerForDismiss al (using:).
Further, the non-interactive animation management instances B and D switch similarly when the pop-up is returned, and it is also necessary to implement the UIViewControllerAnimatedTransitioning interface provided by the iOS system, where the meaning of the interface is to define a function in the animation management process.
In one example, proxy object B or D implements the following four methods of interface definition:
1. The animation duration returning method comprises the following steps: transitionDuration (using:)
This is an animation duration function whose return value is the total duration of the animation.
2. The animation instance return method comprises the following steps: interruptibleAnimator (using:)
This is a function of returning an animation instance, whose return value is the animation instance. The execution of the animation requires an initial state and a final state, namely: where the view of the view controller of the original page is, where the initial position of the view of the sub-view controller to appear is, where the view of the view controller of the original page is to be, and where the view of the sub-view controller is to be. The animation instance obtains the information from the parameters of the function, can modify the positions by itself, and can customize various complex animations, such as: zoom in, zoom out, page turn, rotate, combinations thereof, and the like.
3. Starting an animation processing method: animateTransition (using:)
This is the function that starts the animation, where the start function of the animation instance is called, starting the animation.
4. The animation end processing method comprises the following steps: animationEnded (_:)
This is a function called after the animation is finished, and related work such as releasing the animation instance after the animation is finished is processed inside.
It should be noted that, the above four methods are called by the iOS system at a proper time, and the embodiment of the present application is only responsible for writing service logic therein.
Thirdly, constructing an animation instance. According to different business requirements, an animation instance needs to be constructed, the animation instance is constructed in advance and stored in a global list of the system, and references are put into a dictionary. Doing so can multiplex animation instances, avoiding duplicate codes and multiple identical instances.
Further, in order to enable the actual pop-up or close action to occur, the embodiment of the present application invokes the pop-up or close function of the iOS system, and takes the child view controller as the first parameter to be entered, and the second parameter of the function is a boolean value, which means whether the default animation is required.
Further, for proxy object D, the animation when the child view disappears is actually an inverse process of the child view, and the system still calls four proxy functions, namely, a function transitionDuration (using:) for setting the animation duration, a function interruptibleAnimator (using:), a function animateTransition (using:) for starting the animation, and a function animationEnded (using:) for executing the operation after the animation is finished. In interruptibleAnimator (using:) functions, the view controllers corresponding to the initial state and the final state of the animation execution are reversed, so that only the parameters of the initial state and the final state are judged, and the animation when disappeared is constructed. This disappearing animation is also put into the global list of the system, placing the references into the dictionary.
Further, the embodiment of the application also provides an implementation flow for constructing the sub-view popup presentation mode, which specifically comprises the following steps:
First, a custom pop-up presentation mode is set. In this step, attribute modalPresentationStyle of the child view controller (the controller that actually manages popup) is set to. Custom, which represents a custom presentation style, rather than using several popup styles that are default to the system.
Second, the proxy object during the pop-up and shutdown process is specified. Let the aforementioned proxy object X of the child view controller (controller that actually manages popup) implement another proxy method: presentationCo ntroller (forPresented: presentation: source:), an object F is returned. The type of the object F is UIPresentationController classes provided by the iOS system, and the instance F is generated by using an initialization method init (PRESENTEDVIEWC ONTROLLER: presenting).
In practice, the object F may control many details in the process of ejecting the view, including the final size and position of the sub-views, and additional views may be added during the ejection and closing process, etc. These can be achieved by overwriting UIPresentationController classes of methods.
For example, the dimensions of the return sub-view controller in the frameOfPresentedViewInContainerView method are: upper left corner x point coordinates: 40, upper left corner y point coordinates: 40, width: screen width-40, height: screen height-40. In this way, the sub-view does not occupy all of the area of the screen, and the content of the original page is partially visible to the user.
Then, a blurring effect can be added to the original page according to the service requirement. A method presentationTransitionWillBegin of overwriting an object F, in which the following logic is written: the contai nerView attribute of object F is obtained, which is the container of one of the original page views that is temporarily generated by the current system. A blurred view is then constructed and inserted containerView at the upper layer, i.e., layer 0, of the original page view. Finally, the size of the blurred view is set to be the same as the size of the original page view.
In addition, a method dismissalTransitionWillBegin of overwriting the object F is also required, in which the following logic is written: in the dismissalTransitionWillBegin method, the containerVie w attribute of the object F is obtained, which is a container temporarily generated by the current system and containing the original page view, and then the blurred view is taken out, and a vanishing animation is constructed, so that the blurred view is gradually vanished.
In one example, if the child view to be popped up has rounded edges, the PRESENT EDVIEW attributes of object F may be overwritten, where the attributes PRESENTEDVIEW are acquired, i.e., the child view is popped up, and then the popped up child view is set to rounded edges.
Through the steps, the embodiment of the application realizes the animation management when the jump mode is the pop-up and closing jump mode, so that the jump between the view controllers is more vivid and personalized, and the reusability and maintainability of codes are improved.
In some embodiments, when the jump mode is a custom jump mode, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises: constructing a child view controller, establishing a father-son relationship between a father view controller and the child view controller, setting a proxy object of the father view controller, wherein the proxy object is used for returning a fourth animation management instance, and the fourth animation management instance is used for realizing a view controller jump interface, wherein the view controller jump interface is used for defining an animation duration return method, an animation instance return method, a starting animation processing method and an animation ending processing method.
Specifically, when the jump mode is a custom jump mode, constructing a child view controller, and establishing a parent-child relationship between a parent view controller and the child view controller. In this process, a proxy object for the parent view controller needs to be set, which will return a fourth animation management instance that is used to implement the view controller hop interface. The view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method.
The parent-child relationship between parent view controller and child view controller, and the process of constructing child view pop-up presentation mode are described below with reference to the accompanying drawings and specific embodiments. As shown in fig. 3, fig. 3 is a schematic structural diagram of a hierarchical relationship of a parent-child view controller constructed in an actual scenario according to an embodiment of the present application. The embodiment of the application constructs a sub-view popup presentation mode, which specifically comprises the following steps:
First, a parent-child view controller hierarchy is constructed. The child view controller is taken as the subordinate of the view controller of the current page, and if a plurality of new child views need to appear, the view controller of the current page has a plurality of subordinate.
Next, a switching logic manager is constructed. A switching logic manager is generated, and the switching action of the father-son view controller of the whole App is performed by calling the switching API of the logic manager. The switch logic manager includes the following three APIs:
(1) A child view controller API is added for calling when a child view controller has never been added to a parent view controller.
The inclusion of the API includes: a parent view controller (reference), a child view controller (reference, which is at the final location of the parent view controller), and a logical callback function after the child view controller appears.
The running logic of the API includes:
1) Invoking the join view controller function (addChild:) provided by the iOS system to prepare the child view controller to join the parent view controller.
2) The child view is added to the parent view and the final position is determined.
3) The confirm join view controller function provided by the iOS system is called func didMove (toParent parent: UIViewController |)), which finally joins the child view controller to the parent view controller.
4) The "logical callback function after child view controller appearance" is called, for example: the parent view controller is hidden.
(2) The delete child view controller API is used to call when a child view controller is no longer needed, deleted from the parent view controller.
The inclusion of the API includes: a parent view controller (reference), a child view controller (reference, which is at the final location of the parent view controller), and a logical callback function after the child view controller appears.
The running logic of the API includes:
1) Invoking a pre-removal view controller function (willMove (toParent:)) provided by the iOS system, prepares the child view controller for removal from the parent view controller.
2) The child view is removed from the parent view.
3) The confirm removal view controller function provided by the iOS system is invoked (removeFromParent) to eventually remove the child view controller from the parent view controller.
4) The "logical callback function after child view controller appearance" is called, for example: the parent view controller is displayed.
(3) An API for switching among a plurality of child view controllers is used for calling when the child view controllers are added into a parent controller, a user changes from one control A on a page to click on another control B, and the child view also changes from the child view corresponding to A to the child view corresponding to B.
The inclusion of the API includes: a parent view controller (reference), a child view controller to be switched (reference), a child view controller to be used (reference, which is at the final position of the parent view controller), an animation duration, a switching animation (switching animation provided by the selection system).
The running logic of the API includes:
1) The "child view controller to be put into use" is added to the parent view controller as needed. By "as needed" is meant herein: if this child view controller already exists in the parent view controller, no duplicate additions are needed, and if not already exists, an API is called for additions.
2) The "child view controller to be switched" is removed from the parent view controller as needed. By "as needed" is meant herein: if the child view controller already exists in the parent view controller and can be determined to be no longer used later, calling an API to delete; if it is to be used later, it is not deleted.
3) And switching the switching function (transition (from, to, duration, options:) { } complex: { }) provided by the iOS system by calling the parent view controller, wherein 4 parameters needed by the switching function are 4 parameters of the API.
The three APIs provided in the above embodiments enable a custom pop-up presentation, where the final position of the child view controller within the parent view controller determines any position where the child view controller may appear in any size on the parent view controller. After the child view controller pops up, any pages of the parent view controller may be hidden, achieving the aforementioned overlay effect.
Finally, to achieve custom animation, custom pop-up and closed animations are required. The ejecting and closing modes provided by the foregoing embodiments may be employed. In this process, the popup and the closed animations need to be managed and controlled by the fourth animation management instance.
In some embodiments, the method further comprises: responding to gesture operation of a user on the function control, controlling the proxy object to return an interactive animation management instance, wherein the interactive animation management instance is used for realizing an interactive view controller jump interface, and the interactive view controller jump interface is used for generating an animation instance and saving parameter context of the animation instance; and calling the jump function, executing actual jump action in the gesture response function based on a user gesture predefined on the original page, wherein the jump action comprises calling the jump function when the gesture starts, updating the animation progress when the gesture changes so as to keep the moving distance of the animation and the gesture consistent, and judging to play the animation reversely or continue the animation according to the current moving percentage when the gesture is completed.
Specifically, if the user gesture is not needed in the process of switching the page and the view, the view can be jumped by using the jumped mode provided by the foregoing embodiment. But if user gesture intervention is required during the switching of pages and views, for example: some views are presented that require user intervention. Like the user dragging a button, this button moves all the way with the user's finger; or the user's fingers may be turned over like a book to turn over multiple advertisements, etc. Therefore, the embodiment of the application also provides a view jump method capable of realizing interactive animation. Taking the first jump mode (i.e. the modes of stacking and popping) as an example, the following may be specifically included:
Responding to gesture operation of a user on the function control, and returning the interactive animation management instance through the control proxy object to realize an interactive view controller jump interface. The interface is used to generate animation instances and save their context. By invoking the jump function, the actual jump action may be performed in the gesture response function based on the predefined user gesture on the original page.
In a specific example, assume a view controller that includes a button. When the user drags the button, a jump motion of a view controller is desired, and the jump motion needs to follow the gesture movement of the user, then the interactive animated view jump method may comprise the steps of:
First, a proxy object named a is created. This object is a proxy for the navigation bar controller (the parent controller that actually manages the outgoing stack). Here, another role of proxy object a is to return an interactive animation management instance. Specifically, object a implements the following proxy approach to interactive animation management:
func navigationController(_navigationController:UINavigationController,
interactionControllerFor animationController:UIViewController AnimatedTransitioning)
->UIViewControllerInteractiveTransitioning!
The proxy method returns an object named C. This object C implements the UIViewControllerInteractiveTransitioning interface provided by the iOS system. The interface defines a method (void)star tInteractiveTransition:(id<UIViewControllerContextTransitioning>)transitionCo ntext; that is called by the iOS system at the appropriate time, and the embodiment of the application only needs to write business logic in this method. For example, object C needs to generate an animation instance and save its context in startInteractiveTransition methods.
Then, a user gesture is defined on the original page and added to the page. In the response function of the gesture, the actual push action is invoked, for example: like the user dragging a button that moves with the user's finger, the end user releases the finger and the button automatically moves to a predetermined position.
Further, based on the predefined swipe gesture on the original page, performing an actual jump action in the gesture response function, where the specific jump action includes the following:
When the gesture starts, a push action starts to be performed. And when the gesture changes, updating the progress of the animation. The previously saved context is obtained and called updateInteractiveTransition a method, taking the percentage of gesture movement as a parameter. This ensures that the movements of the animation and gesture remain exactly identical. The calculation formula of the percentage is: the distance increment moved by the gesture is divided by (button end position minus button initial position). When the gesture is completed (i.e., when the user lifts the finger), it is decided whether to play the animation in reverse or continue according to the current movement percentage.
It should be noted that, the displacement distance of the gesture determines whether the button returns to the initial position or to the end position, and if the distance moved by the user is small (less than 50%), the animation is played in reverse, so that the button returns to the initial position. If the distance moved by the user is larger (greater than or equal to 50%), continuing to play the animation, and moving the button to the end position. In addition, it should be noted that the object A, B, C may be the same object or different objects.
In some embodiments, the method further comprises: responding to gesture operation of a user on the function control, controlling the proxy object to return an interactive animation management instance, wherein the interactive animation management instance is used for realizing an interactive view controller jump interface, and the interactive view controller jump interface is used for generating an animation instance and saving parameter context of the animation instance; wherein the animation instance is an attribute animation class (UIVie wPropertyAnimator) instance provided by the iOS system; and calling a skip function, executing actual skip action in a gesture response function based on a user gesture predefined on an original page, wherein the skip action comprises calling a pause animation function of an attribute animation instance when the gesture starts, executing gesture action of a user when the gesture changes, and judging to play the animation reversely or continue the animation according to the current movement percentage when the gesture is completed.
In particular, in addition to the method for jumping views of an interactive animation provided in the foregoing embodiment, the embodiment of the present application provides another implementation manner of jumping views of an interactive animation by modifying the process of jumping views of a first interactive animation. The following describes the implementation process of the view jump of the modified interactive animation in detail in connection with the specific embodiment, and may specifically include the following:
Responding to gesture operation of a user on a certain function control. To this end, a proxy object is controlled to return an interactive animation management instance. This instance may implement an interactive view controller jump interface that may generate an attribute animation instance (an animation type provided by the iOS system) and save the parameter context of this animation instance.
Further, the actual jumping actions may be performed on the original page based on predefined user gestures by invoking a jumping function. In particular, when a gesture begins, a pause animation function of the property animation instance may be invoked. Then, as the gesture changes, a gesture action of the user may be performed. Finally, when the gesture is completed, whether the animation should be played back or continued to be played back can be determined according to the current movement percentage.
Another interactive animated view jump method will be described in detail below. In this approach, object a implements a proxy approach to interactive animation management, while the actual jumping actions performed in the gesture response function are different from the first interactive animation's view jumping approach described above.
In iOS systems, animations are mainly of four types: view animation, layer animation, implicit animation, and attribute animation (UIViewPropertyAnimator). Attribute animation supports pausing and continuing the animation, while others do not directly support, requiring detour skills if to do so. In the technical scheme of the application, firstly, the animation instance generated in the first interactive animation view jump method is an attribute animation, namely a UIViewPropertyAnimator class instance. Then, the jump actions executed in the gesture response function in the first interactive animation view jump method are adjusted as follows:
1) And calling an actual push action, and executing the animation by the system by itself when no user gesture is in-between.
2) When a gesture is entered by a user: a user gesture is defined and added to the original page. Then, judging the state of the gesture in the gesture response function:
when the gesture just begins, a pause animation function is invoked on the animation instance (pauseAnimation).
In the gesture process, a gesture action of the user is performed.
When the gesture ends, a continue animation function is invoked on the animation instance (continueAnimation (WITHTI MINGPARAMETERS:, durationFactor:)). Meanwhile, whether to play the animation reversely or continue to play the animation is determined according to the percentage of the current movement. If reverse play is required, the continue animation function is called after the IS REVERSED attribute of the animation instance is set to true.
According to the technical scheme provided by the embodiment of the application, the scheme of replacing view pop-up by the view controller is provided, and the customization effect is improved by means of the four-large view controller switching technology provided by the iOS. The technical scheme of the application achieves the following advantages and technical effects in the implementation process:
1. The goal of MVC layering is achieved: the application clearly distinguishes the responsibilities of the view, the view controller and the model, and allows each part to concentrate on the task of the device, thereby obviously improving the code readability and simplifying the later maintenance work.
2. A good hierarchical relationship is formed with the existing view: the application organizes views hierarchically so that they can be compatible with view-level tree management calls of the iOS system, greatly reducing the possibility of bug occurrence.
3. Unified management of animation at appearance and end of view is realized: the application carries out unified management on the animation, reusable sub-views and creation manager of the appearance and the end of the view, and is beneficial to maintaining the style consistency of the application program.
4. Covering all sub-view occurrences: the application can well process various view occurrence situations needing user participation. For example, when a user drags a button, the button will follow the user's finger movement; when the user turns the advertisement page like turning a book, the switching of the views can be smoothly performed.
Therefore, the embodiment of the application provides an improved self-defining effect, including animation and coverage modes, and provides a new scheme for replacing view pop-up by a view controller on the basis, which is beneficial to realizing clear layering of codes, improving system stability, keeping style consistency of application programs and well processing various interactive scenes needing user participation.
The following are examples of the apparatus of the present application that may be used to perform the method embodiments of the present application. For details not disclosed in the embodiments of the apparatus of the present application, please refer to the embodiments of the method of the present application.
Fig. 4 is a schematic structural diagram of a page-based view controller jumping device according to an embodiment of the present application. As shown in fig. 4, the page-based view controller jumping device includes:
the response module 401 is configured to respond to clicking operation of a user on a function control in a page of an application program, and pop up a child view controller corresponding to the function control by using the parent view controller;
the query module 402 is configured to query a dictionary of the application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a skip mode and skip execution logic;
The calling module 403 is configured to call a jump function corresponding to a predetermined jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of the proxy object of the parent view controller, where the method of the proxy object is used to control the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump.
In some embodiments, the creating module 404 of fig. 4 creates a dictionary in memory at the start of the application before querying the dictionary of the application, the dictionary containing a plurality of key-value pairs, each key-value pair being used to characterize configuration information corresponding to one sub-view controller in the page; wherein the keys in the key-value pair are used to identify the parent view by a globally unique string and the values in the key-value pair are used to store configuration information.
In some embodiments, when the jump mode is a push and pop jump mode, the calling module 403 of fig. 4 sets a proxy object of the navigation bar controller before the jump function triggers the system to execute the method of the proxy object of the parent view controller, where the proxy object is used to return a first animation management instance, the first animation management instance is used to implement a view controller jump interface, where the view controller jump interface is used to define an animation duration return method, an animation instance return method, a start animation processing method, and an animation end processing method, and the navigation bar controller is used to characterize the parent view controller that is actually managing the push.
In some embodiments, when the skip mode is a switched skip mode, the calling module 403 of fig. 4 sets a proxy object of the partition controller before the skip function triggers the system to execute the method of the proxy object of the parent view controller, where the proxy object is used to return a second animation management instance, and the second animation management instance is used to implement a view controller skip interface, where the view controller skip interface is used to define an animation duration return method, an animation instance return method, a start animation processing method, and an animation end processing method, and the partition controller is used to characterize the parent view controller that actually manages the switch.
In some embodiments, when the skip mode is a pop-up and close skip mode, the calling module 403 of fig. 4 sets a proxy object for the child view controller before the skip function triggers the system to execute the method of the proxy object for the parent view controller, the proxy object being used to return a third animation management instance, wherein the third animation management instance is used to characterize interactive and non-interactive animation management instances when popping up and closing; the third animation management instance is used for realizing a view controller jump interface, wherein the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method.
In some embodiments, when the jump mode is a custom jump mode, the calling module 403 of fig. 4 constructs a child view controller, establishes a parent-child relationship between the parent view controller and the child view controller, sets the proxy object of the parent view controller, and uses the proxy object to return to a fourth animation management instance, where the fourth animation management instance is used to implement a view controller jump interface, and the view controller jump interface is used to define an animation duration return method, an animation instance return method, a start animation processing method, and an animation end processing method.
In some embodiments, the invoking module 403 of fig. 4 is configured to control the proxy object to return an interactable animation management instance in response to a gesture operation of the user on the functionality control, the interactable animation management instance being configured to implement an interactable view controller jump interface, the interactable view controller jump interface being configured to generate an animation instance and to save a parameter context of the animation instance; and calling the jump function, executing actual jump action in the gesture response function based on a user gesture predefined on the original page, wherein the jump action comprises calling the jump function when the gesture starts, updating the animation progress when the gesture changes so as to keep the moving distance of the animation and the gesture consistent, and judging to play the animation reversely or continue the animation according to the current moving percentage when the gesture is completed.
In some embodiments, the invoking module 403 of fig. 4 is configured to control the proxy object to return an interactable animation management instance in response to a gesture operation of the user on the functionality control, the interactable animation management instance being configured to implement an interactable view controller jump interface, the interactable view controller jump interface being configured to generate an animation instance and to save a parameter context of the animation instance; wherein, the animation instance is an attribute animation instance provided by the iOS system; and calling a skip function, executing actual skip action in a gesture response function based on a user gesture predefined on an original page, wherein the skip action comprises calling a pause animation function of an attribute animation instance when the gesture starts, executing gesture action of a user when the gesture changes, and judging to play the animation reversely or continue the animation according to the current movement percentage when the gesture is completed.
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, and should not limit the implementation process of the embodiment of the present application.
Fig. 5 is a schematic structural diagram of an electronic device 5 according to an embodiment of the present application. As shown in fig. 5, the electronic apparatus 5 of this embodiment includes: a processor 501, a memory 502 and a computer program 503 stored in the memory 502 and executable on the processor 501. The steps of the various method embodiments described above are implemented by processor 501 when executing computer program 503. Or the processor 501 when executing the computer program 503 performs the functions of the modules/units in the above-described apparatus embodiments.
Illustratively, the computer program 503 may be split into one or more modules/units, which are stored in the memory 502 and executed by the processor 501 to complete the present application. One or more of the modules/units may be a series of computer program instruction segments capable of performing a specific function for describing the execution of the computer program 503 in the electronic device 5.
The electronic device 5 may be a desktop computer, a notebook computer, a palm computer, a cloud server, or the like. The electronic device 5 may include, but is not limited to, a processor 501 and a memory 502. It will be appreciated by those skilled in the art that fig. 5 is merely an example of the electronic device 5 and is not meant to be limiting as the electronic device 5 may include more or fewer components than shown, or may combine certain components, or different components, e.g., the electronic device may further include an input-output device, a network access device, a bus, etc.
The Processor 501 may be a central processing unit (Central Processing Unit, CPU), but may also be other general purpose processors, digital signal processors (DIGITAL SIGNAL Processor, DSP), 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, etc. A general purpose processor may be a microprocessor or the processor may be any conventional processor or the like.
The memory 502 may be an internal storage unit of the electronic device 5, for example, a hard disk or a memory of the electronic device 5. The memory 502 may also be an external storage device of the electronic device 5, such as a plug-in hard disk, a smart memory card (SMART MEDIA CARD, SMC), a Secure Digital (SD) card, a flash memory card (FLASH CARD) or the like, which are provided on the electronic device 5. Further, the memory 502 may also include both internal storage units and external storage devices of the electronic device 5. The memory 502 is used to store computer programs and other programs and data required by the electronic device. The memory 502 may also be used to temporarily store data that has been output or is to be output.
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. In addition, the specific names of the functional units and modules are only for distinguishing from each other, and are not used for limiting the protection scope of the present application. The specific working process of the units and modules in the above system may refer to the corresponding process in the foregoing method embodiment, which is not described herein again.
In the foregoing embodiments, the descriptions of the embodiments are emphasized, and in part, not described or illustrated in any particular embodiment, reference is made to the related descriptions of other embodiments.
Those of ordinary skill in the art will appreciate that the various illustrative elements and algorithm steps described in connection with the embodiments disclosed herein may be implemented as electronic hardware, or combinations of computer software and electronic hardware. Whether such functionality is implemented as hardware or software depends upon the particular application and design constraints imposed on the solution. Skilled artisans may implement the described functionality in varying ways for each particular application, but such implementation decisions should not be interpreted as causing a departure from the scope of the present application.
In the embodiments provided by the present application, it should be understood that the disclosed apparatus/computer device and method may be implemented in other manners. For example, the apparatus/computer device embodiments described above are merely illustrative, e.g., the division of modules or elements is merely a logical functional division, and there may be additional divisions of actual implementations, multiple elements or components may be combined or integrated into another system, or some features may be omitted, or not performed. Alternatively, the coupling or direct coupling or communication connection shown or discussed may be an indirect coupling or communication connection via interfaces, devices or units, which may be in electrical, mechanical or other forms.
The units described as separate units may or may not be physically separate, and units shown as units may or may not be physical units, may be located in one place, or may be distributed over a plurality of network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
In addition, each functional unit in the embodiments of the present application 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. The integrated units may be implemented in hardware or in software functional units.
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 may implement all or part of the flow of the method of the above embodiment, 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, when executed by a processor, may implement the steps of each of the method embodiments described above. 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. It should be noted that the content of the computer readable medium can be appropriately increased or decreased according to the requirements of the jurisdiction's jurisdiction and the patent practice, for example, in some jurisdictions, the computer readable medium does not include electrical carrier signals and telecommunication signals according to the jurisdiction and the patent practice.
The above embodiments are only for illustrating the technical solution of the present application, and are not limiting; although the application has been described in detail with reference to the foregoing embodiments, it will 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 (9)

1. A method for jumping a view controller based on a page, comprising:
responding to clicking operation of a user on a function control in a page of an application program, and popping up a child view controller corresponding to the function control by utilizing a father view controller;
Inquiring a dictionary of an application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a skip mode and skip execution logic;
Calling a preset jump function corresponding to the jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers a system to execute a method of a proxy object of a parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump;
The jump mode comprises a push and pop mode, a switching mode, a user-defined mode and a pop and close mode; before querying the dictionary of the application, the method further comprises:
creating a dictionary in a memory when an application program is started, wherein the dictionary comprises a plurality of key value pairs, and each key value pair is used for representing configuration information corresponding to one sub-view controller in the page; wherein keys in the key-value pair are used to identify a parent view through a globally unique string, and values in the key-value pair are used to store the configuration information.
2. The method of claim 1, wherein when the jump pattern is a jump pattern of a push and a pop, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises:
The method comprises the steps of setting a proxy object of a navigation bar controller, wherein the proxy object is used for returning a first animation management instance, the first animation management instance is used for realizing a view controller jump interface, the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method, and the navigation bar controller is used for representing a father view controller actually managing an outgoing stack.
3. The method of claim 1, wherein when the jump mode is a switched jump mode, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises:
And setting a proxy object of the partition controller, wherein the proxy object is used for returning a second animation management instance, the second animation management instance is used for realizing a view controller jump interface, the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method, and the partition controller is used for representing a father view controller actually managing switching.
4. The method of claim 1, wherein when the jump mode is a pop-up and close jump mode, before the jump function triggers the system to execute the method of the proxy object of the parent view controller, the method further comprises:
setting a proxy object of the sub-view controller, wherein the proxy object is used for returning a third animation management instance, and the third animation management instance is used for representing interactive and non-interactive animation management instances when popping up and closing;
the third animation management instance is used for realizing a view controller jump interface, wherein the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method.
5. The method of claim 1, wherein when the jump pattern is a custom jump pattern, the method further comprises, before the jump function triggers the system to execute the method of the proxy object of the parent view controller:
Constructing a child view controller, establishing a father-son relationship between a father view controller and the child view controller, and setting a proxy object of the father view controller, wherein the proxy object is used for returning a fourth animation management instance, and the fourth animation management instance is used for realizing a view controller jump interface, wherein the view controller jump interface is used for defining an animation duration returning method, an animation instance returning method, a starting animation processing method and an animation ending processing method.
6. The method according to any one of claims 2 to 5, further comprising:
Responding to gesture operation of a user on the functional control, controlling the proxy object to return an interactive animation management instance, wherein the interactive animation management instance is used for realizing an interactive view controller jump interface, and the interactive view controller jump interface is used for generating an animation instance and saving parameter context of the animation instance;
and calling the jump function, executing actual jump action in a gesture response function based on a user gesture predefined on an original page, wherein the jump action comprises calling the jump function when the gesture starts, updating the animation progress when the gesture changes so as to keep the moving distance of the animation and the gesture consistent, and judging to play the animation reversely or continue the animation according to the current moving percentage when the gesture is completed.
7. The method according to any one of claims 2 to 5, further comprising:
responding to gesture operation of a user on the functional control, controlling the proxy object to return an interactive animation management instance, wherein the interactive animation management instance is used for realizing an interactive view controller jump interface, and the interactive view controller jump interface is used for generating an animation instance and saving parameter context of the animation instance; wherein, the animation instance is an attribute animation instance provided by the iOS system;
And calling the jump function, executing actual jump action in a gesture response function based on a user gesture predefined on an original page, wherein the jump action comprises calling a pause animation function of the attribute animation instance when the gesture starts, executing gesture action of a user when the gesture changes, and judging to play the animation reversely or continue the animation according to the current moving percentage when the gesture is completed.
8. A page-based view controller jump device, comprising:
The response module is configured to respond to clicking operation of a user on a function control in a page of an application program, and pop up a child view controller corresponding to the function control by using a parent view controller;
The query module is configured to query a dictionary of the application program to obtain configuration information corresponding to the sub-view controller, wherein the configuration information comprises references of the sub-view controller, view animation, view ending animation, a jump mode and jump execution logic;
The calling module is configured to call a preset jump function corresponding to the jump mode according to the jump mode corresponding to the child view controller, so that the jump function triggers the system to execute a method of a proxy object of a parent view controller, wherein the method of the proxy object is used for controlling the jump of the child view controller, and the proxy object of the parent view controller is a preset custom object for managing the jump;
The creating module is configured to create a dictionary of the application program in a memory when the application program is started before inquiring the dictionary of the application program, wherein the dictionary comprises a plurality of key value pairs, and each key value pair is used for representing configuration information corresponding to one sub-view controller in the page; wherein, the keys in the key value pair are used for identifying the father view through the globally unique character string, and the values in the key value pair are used for storing the configuration information;
The jump mode comprises a push and pop mode, a switching mode, a user-defined mode and a pop and close mode.
9. A computer readable storage medium storing a computer program, characterized in that the computer program when executed by a processor implements the method according to any one of claims 1 to 7.
CN202310961007.9A 2023-07-28 2023-07-28 Page-based view controller jump method, device and storage medium Active CN116974678B (en)

Priority Applications (1)

Application Number Priority Date Filing Date Title
CN202310961007.9A CN116974678B (en) 2023-07-28 2023-07-28 Page-based view controller jump method, device and storage medium

Applications Claiming Priority (1)

Application Number Priority Date Filing Date Title
CN202310961007.9A CN116974678B (en) 2023-07-28 2023-07-28 Page-based view controller jump method, device and storage medium

Publications (2)

Publication Number Publication Date
CN116974678A CN116974678A (en) 2023-10-31
CN116974678B true CN116974678B (en) 2024-08-09

Family

ID=88484648

Family Applications (1)

Application Number Title Priority Date Filing Date
CN202310961007.9A Active CN116974678B (en) 2023-07-28 2023-07-28 Page-based view controller jump method, device and storage medium

Country Status (1)

Country Link
CN (1) CN116974678B (en)

Families Citing this family (2)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN118092994B (en) * 2024-02-23 2025-09-05 重庆赛力斯凤凰智创科技有限公司 Method and device for implementing map encapsulator for vehicle control application
CN119396393A (en) * 2024-09-20 2025-02-07 成都赛力斯科技有限公司 Interface switching animation implementation method and implementation device

Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463367A (en) * 2017-06-22 2017-12-12 北京小度信息科技有限公司 Transition cartoon implementing method and device

Family Cites Families (7)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
WO2014134938A1 (en) * 2013-03-07 2014-09-12 Tencent Technology (Shenzhen) Company Limited View mode switch of graphical user interface
US9880861B2 (en) * 2013-06-05 2018-01-30 Tencent Technology (Shenzhen) Company Limited Method and apparatus for page view switching
CN115933946A (en) * 2021-09-30 2023-04-07 腾讯科技(深圳)有限公司 Page jump method, device, computer equipment and storage medium
CN114692056A (en) * 2022-04-26 2022-07-01 康键信息技术(深圳)有限公司 Target page generation method, apparatus, computer equipment and storage medium
CN115145676B (en) * 2022-09-05 2023-01-06 飞狐信息技术(天津)有限公司 Information interaction method and system
CN115756222A (en) * 2022-10-31 2023-03-07 成都赛力斯科技有限公司 Application program skin changing method and device, computer equipment and storage medium
CN116185402A (en) * 2022-12-30 2023-05-30 成都赛力斯科技有限公司 Method and device for creating pop-up view, computer equipment and storage medium

Patent Citations (1)

* Cited by examiner, † Cited by third party
Publication number Priority date Publication date Assignee Title
CN107463367A (en) * 2017-06-22 2017-12-12 北京小度信息科技有限公司 Transition cartoon implementing method and device

Also Published As

Publication number Publication date
CN116974678A (en) 2023-10-31

Similar Documents

Publication Publication Date Title
CN116974678B (en) Page-based view controller jump method, device and storage medium
US7536650B1 (en) System and method that facilitates computer desktop use via scaling of displayed objects with shifts to the periphery
US9671922B1 (en) Scaling of displayed objects with shifts to the periphery
US8578271B2 (en) Nested roadmap navigation in a graphical user interface
US7386801B1 (en) System and method that facilitates computer desktop use via scaling of displayed objects with shifts to the periphery
US10775971B2 (en) Pinch gestures in a tile-based user interface
JP6273354B2 (en) User interface elements for multiple displays
US5611031A (en) Graphical user interface for modifying object characteristics using coupon objects
CN102356375B (en) Smooth layout animation of continuous and non-continuous properties
CN109782977B (en) View processing method, electronic device and storage medium
US9223589B2 (en) Smooth layout animation of visuals
CN103793134A (en) Touch screen terminal and multi-interface switching method thereof
KR20080026597A (en) Smooth transitions between animations
CN102221993A (en) Declarative definition of complex user interface state changes
CN109471580B (en) Visual 3D courseware editor and courseware editing method
CN113926190A (en) Method and device for controlling three-dimensional model in game editor and storage medium
CN116661785A (en) iOS-based progress bar implementation method and device, electronic equipment and storage medium
US20140325404A1 (en) Generating Screen Data
Dessart et al. Animated transitions between user interface views
WO2025139467A1 (en) Infinite sliding method, terminal device, and computer-readable storage medium
WO2025044582A1 (en) Page management method and apparatus for virtual game, electronic device, and storage medium
CN113360154A (en) Page construction method, device, equipment and readable medium
US20230066691A1 (en) Windowing container
CN111352615A (en) Data display method and terminal based on pie chart component with background animation
CN112817508B (en) Method, device and equipment for managing gesture control instruction of resource material

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
TA01 Transfer of patent application right

Effective date of registration: 20240116

Address after: No. 13 Xingxiang Road, Zengjia Town, High tech Zone, Shapingba District, Chongqing, 400039

Applicant after: Chongqing Selis Phoenix Intelligent Innovation Technology Co.,Ltd.

Address before: 401120 No. 618 Liangjiang Avenue, Longxing Town, Yubei District, Chongqing City

Applicant before: Chongqing Celes New Energy Automobile Design Institute Co.,Ltd.

TA01 Transfer of patent application right
GR01 Patent grant
GR01 Patent grant