A scroll view control method, device, equipment and storage medium
By monitoring the trigger event and obtaining relevant parameters, the scrolling of the nested second scroll view is solved, and the problem of gesture conflict in the nested scroll view is achieved, and effective control of the second scroll view is achieved.
Patent Information
- Application Number
- CN202010671077.7
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2020-07-13
- Publication Date
- 2025-02-21
- Estimated Expiration
- 2040-07-13
AI Technical Summary
When nesting two scroll views together, it is impossible to distinguish which scroll view the scroll gesture acts on, resulting in gesture conflicts.
By monitoring the trigger event, obtaining the initial margin and the first offset of the first scroll view, the scroll parameters of the second scroll view are determined, and the scrolling of the second scroll view is controlled according to these parameters.
The gesture conflict problem in nested scroll views is solved, and the scrolling of the second scroll view is controlled through the first scroll view, making the operation more convenient.
Smart Images

Figure CN113760163B_ABST
Abstract
Description
Technical Field
[0001] Embodiments of the present invention relate to the field of computer application technology, and in particular to a scroll view control method, device, equipment and storage medium. Background Art
[0002] In the software development process, for the scroll view UIScrollView provided by the iOS system, there is sometimes a need to nest two scrolling methods with the same UIScrollView.
[0003] In the process of implementing the present invention, the inventors discovered that the following technical problems exist in the prior art: after two scrolling views with the same UIScrollView are nested together, when a scrolling gesture is applied to the overlapping area of the two views, it is impossible to distinguish which UIScrollView the scrolling gesture is applied to, which causes a gesture conflict problem in the nested scrolling views. Summary of the invention
[0004] The embodiments of the present invention provide a scroll view control method, device, equipment and storage medium, which solve the problem of gesture conflict in mutually nested scroll views.
[0005] In a first aspect, an embodiment of the present invention provides a scroll view control method, which is applied to a view controller, wherein a first scroll view and a second scroll view nested in the first scroll view are provided in the view controller, and the method may include:
[0006] When a trigger event for controlling a scroll view is detected, an initial margin and a first offset of the first scroll view corresponding to the trigger event are obtained, wherein the initial margin is a margin of the second scroll view relative to the first scroll view in a scrolling direction of the second scroll view;
[0007] According to the first offset and the initial margin, a scrolling parameter of the second scrolling view is determined, and the second scrolling view is controlled to scroll according to the scrolling parameter.
[0008] Optionally, the scrollable range of the first scroll view in the scrolling direction is the sum of the scrollable range of the second scroll view in the scrolling direction and the initial margin.
[0009] Optionally, determining the scrolling parameter of the second scroll view according to the first offset and the initial margin may include:
[0010] If the first offset is greater than the initial margin, the target margin of the second scroll view is set to the first offset, and the second offset of the second scroll view is set to the difference between the first offset and the initial margin.
[0011] Optionally, determining the scrolling parameter of the second scroll view according to the first offset and the initial margin may include:
[0012] If the first offset is less than the initial margin, the target margin of the second scroll view is set to the initial margin, and the second offset of the second scroll view is set to 0.
[0013] Optionally, the scrolling parameters include a second offset and a target margin, and controlling the second scroll view to scroll according to the scrolling parameters may include:
[0014] The second scroll view is controlled to scroll according to the target margin, and the second content view set in the second scroll view is controlled to scroll according to the second offset.
[0015] Optionally, the scroll view control method may further include:
[0016] The first content view set in the first scroll view is controlled to scroll according to the first offset.
[0017] Optionally, the agent of the first scroll view is a view controller; obtaining the first offset of the first scroll view corresponding to the triggering event may include:
[0018] Sending a trigger event to a first scroll view corresponding to the agent, so that the first scroll view triggers a preset notification function according to the trigger event;
[0019] A first offset of the first scroll view is obtained according to a preset notification function.
[0020] In a second aspect, an embodiment of the present invention further provides a scroll view control device, which is configured in a view controller, wherein a first scroll view and a second scroll view nested in the first scroll view are provided in the view controller, and the device may include:
[0021] A first offset acquisition module is used to acquire an initial margin and a first offset of the first scrolling view corresponding to the triggering event when a triggering event for controlling the scrolling view is detected, wherein the initial margin is a margin of the second scrolling view relative to the first scrolling view in a scrolling direction of the second scrolling view;
[0022] The scroll view control module is used to determine the scroll parameter of the second scroll view according to the first offset and the initial margin, and control the second scroll view to scroll according to the scroll parameter.
[0023] In a third aspect, an embodiment of the present invention further provides a device, which may include:
[0024] one or more processors;
[0025] A memory for storing one or more programs;
[0026] When one or more programs are executed by one or more processors, the one or more processors implement the scroll view control method provided by any embodiment of the present invention.
[0027] In a fourth aspect, an embodiment of the present invention further provides a computer-readable storage medium having a computer program stored thereon, and when the computer program is executed by a processor, the scroll view control method provided by any embodiment of the present invention is implemented.
[0028] The technical solution of the embodiment of the present invention can obtain the initial margin and the first offset of the first scroll view corresponding to the trigger event by monitoring the trigger event of controlling the scroll view; then, according to the numerical relationship between the first offset and the initial margin, the scroll parameter of the second scroll view can be determined, and the scrolling of the second scroll view can be controlled according to the scroll parameter. The above technical solution solves the problem of gesture conflicts in nested scroll views, and the effect of scrolling control of the second scroll view can be achieved through the first scroll view. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 is a flow chart of a scroll view control method in Embodiment 1 of the present invention;
[0030] Figure 2 is a schematic diagram of a scroll view in a scroll view control method in Embodiment 1 of the present invention;
[0031] Figure 3 is a flow chart of a scroll view control method in Embodiment 2 of the present invention;
[0032] Figure 4a is a first application schematic diagram of a scroll view control method in Embodiment 2 of the present invention;
[0033] Figure 4b is a second application schematic diagram of a scroll view control method in Embodiment 2 of the present invention;
[0034] Figure 4c is a third application schematic diagram of a scroll view control method in the second embodiment of the present invention;
[0035] Figure 4d is a fourth application schematic diagram of a scroll view control method in the second embodiment of the present invention;
[0036] Figure 5 is a structural block diagram of a scroll view control device in Embodiment 3 of the present invention;
[0037] Figure 6It is a structural diagram of a device in Embodiment 4 of the present invention. DETAILED DESCRIPTION
[0038] The present invention is further described in detail below in conjunction with the accompanying drawings and embodiments. It is to be understood that the specific embodiments described herein are only used to explain the present invention, rather than to limit the present invention. It is also necessary to explain that, for ease of description, only parts related to the present invention, rather than all structures, are shown in the accompanying drawings.
[0039] Before introducing the embodiment of the present invention, the application scenario of the embodiment of the present invention is first exemplified: the scroll view control method described in the embodiment of the present invention is applied to a view controller (ViewController), and a first scroll view and a second scroll view are provided in the view controller, and the second scroll view is nested in the first scroll view. In other words, the first scroll view can be understood as an external scroll view, and the second scroll view can be understood as an internal scroll view, and the scroll directions of the two are the same, such as horizontal or vertical. A first content view is provided in the first scroll view and a second content view is provided in the second scroll view. The first content view can be scrolled in the first scroll view and the second content view can be scrolled in the second scroll view. A delegate (UIScrollViewDelegate) is added to the view controller, and the delegate (delegate) of the first scroll view is assigned to the view controller, and the delegate (delegate) of the second scroll view is not assigned to the view controller, which means that the scroll control of the first scroll view and the second scroll view can be achieved through one delegate.
[0040] Exemplarily, the first scroll view and the second scroll view can be UIScrollView controls provided by the iOS system that can realize view scrolling. They can have properties such as offset (contentOffset), scrollable range (contentSize), frame (frame), etc. Among them, the offset can reflect the positional relationship between the content view set in the scroll view and the scroll view. For example, the first offset can reflect the positional relationship between the first content view set in the first scroll view and the first scroll view. It can be a CGPoint type of data, and the coordinate origin at this time can be the upper left corner of the first scroll view; the meaning of the second offset is similar and will not be repeated here. The scrollable range can reflect the range in which the scroll view can scroll. For example, the scrollable range of the second scroll view can be within the scrollable range of the first scroll view, which means that the second scroll view will not exceed the scrollable range of the first scroll view when scrolling. The frame can reflect the positional relationship of the second scrolling view in the first scrolling view. It can be a CGRect type data, which can include 4 values, each of which can be the margin between two adjacent borders of the second scrolling view and the first scrolling view, such as the margin between the upper border and the upper border, the margin between the left border and the left border, the margin between the lower border and the lower border, or the margin between the right border and the right border.
[0041] Embodiment 1
[0042] Figure 1 This is a flow chart of a scroll view control method provided in the first embodiment of the present invention. This embodiment is applicable to the case of controlling a scroll view, and is particularly applicable to the case of controlling a second scroll view to scroll based on a first scroll view. The method can be executed by a scroll view control device provided in an embodiment of the present invention, which can be implemented by software and / or hardware, and which can be configured in a view controller, which can be integrated in a device, and which can be various user terminals or servers.
[0043] See also Figure 1 The method of the embodiment of the present invention specifically includes the following steps:
[0044] S110 . When a triggering event for controlling a scrolling view is detected, an initial margin and a first offset of a first scrolling view corresponding to the triggering event are obtained.
[0045] Among them, the initial margin is the margin of the second scroll view relative to the first scroll view in the scroll direction of the second scroll view, and the scroll direction is also the scroll direction of the first scroll view. The initial margin is the margin of the scroll view before scrolling, which can be a CGFloat type value. Exemplarily, if the scroll direction is vertical, the initial margin can be the margin between the upper boundary and the upper boundary, or the margin between the lower boundary and the lower boundary. At this time, the initial margin can be understood as the initial height; correspondingly, if the scroll direction is horizontal, the initial margin can be the margin between the left boundary and the left boundary, or the margin between the right boundary and the right boundary. At this time, the initial margin can be understood as the initial width.
[0046] Take the vertical scrolling direction as an example. Figure 2 As shown, the initial margin (scrollViewTopPadding) may be the distance between the upper boundary of the first scroll view (mainScrollView) and the upper boundary of the second scroll view (contentScrollView), that is, scrollViewTopPadding = contentScrollView.frame.origin.y.
[0047] After monitoring the trigger event that controls the scroll view, the view controller can obtain the first offset of the first scroll view corresponding to the trigger event. This is because the agent of the first scroll view is the view controller, and the view controller can send the trigger event to the first scroll view. The trigger event can be a scroll gesture applied by the user on the display screen. The scroll gesture can be a sliding operation, a clicking operation, a pressing operation, etc., which are not specifically limited here. After receiving the trigger event, the first scroll view can adjust its own first offset according to the trigger event, and trigger a preset notification function according to the adjustment result. The preset notification function can be a proxy method scrollViewDidScroll:(UIScrollView*)scrollView written in the view controller, and its input parameter scrollView has the attribute contentOffset. Therefore, the view controller can obtain the adjusted first offset according to the preset notification function, and the adjusted first offset is the first offset corresponding to the trigger event.
[0048] S120: Determine a scrolling parameter of the second scrolling view according to the first offset and the initial margin, and control the second scrolling view to scroll according to the scrolling parameter.
[0049] Among them, for the first content view set in the first scrolling view and the second content view set in the second scrolling view, since the first content view and the second content view are always scrolled synchronously, then according to the numerical relationship between the first offset and the initial margin, the positional relationship between the first scrolling view and the second scrolling view can be determined, and then the scrolling parameters of the second scrolling view can be determined, and the scrolling of the second scrolling view can be controlled according to the scrolling parameters.
[0050] Taking into account the application scenarios that may be involved in the embodiments of the present invention, optionally, the scrolling parameters may include a target margin and a second offset, wherein the target margin is the margin of the second scrolling view in the scrolling direction relative to the first scrolling view after scrolling, calculated based on the triggering event, and the second offset is also the relative position of the second content view in the second scrolling view after scrolling, calculated based on the triggering event. Thus, the second scrolling view can be controlled to scroll according to the target margin, and the second content view can be controlled to scroll according to the second offset. Similarly, the first offset is also the relative position of the first content view in the first scrolling view after scrolling, calculated based on the triggering event. Thus, optionally, the first content view can be controlled to scroll according to the first offset.
[0051] It should be noted that, first of all, since the proxy of the first scroll view is assigned to the view controller, and the proxy of the second scroll view is not assigned to the view controller, this means that after the view controller detects the scroll gesture, even if the scroll gesture acts on the overlapping area of the nested scroll views, the view controller can only send the trigger event to the first scroll view, thereby solving the problem of gesture conflicts in the nested scroll views, and only the scroll gesture of the first scroll view is triggered, and the scrolling effect is smoother. Furthermore, the view controller can calculate the scrolling parameters of the second scroll view based on the numerical relationship between the first offset and the initial margin, which means that the scrolling control of the first scroll view and the second scroll view can be achieved through one proxy, or the scrolling control of the second scroll view can be achieved through the first scroll view, which is more convenient.
[0052] Secondly, when controlling the scrolling of the second scroll view according to the scrolling parameters, it is only necessary to set the corresponding scrolling parameters without modifying the code of the second scroll view, thereby reducing the coupling degree of the second scroll view and improving the scalability, and can adapt to scrolling pages with built-in scrollviews such as UIWebview, which will not fail to implement corresponding scrolling due to the inability to monitor scrollViewDidScroll.
[0053] Again, since the scrollable range of the second scrolling view is controllable, the scrollable range may include a scrollable height and a scrollable width. As described in the embodiment of the present invention, the maximum value of the scrollable height of the second scrolling view is the height of the display screen and the maximum value of the scrollable width is the width of the display screen, which means that the displayable portion of the second display content set in the second scrolling view is controllable, thereby saving memory and avoiding memory explosion. Exemplarily, when the second scrolling view is a tableView and there are multiple data inside the tableView that need to be reused through cells, since the maximum value of the scrollable height of the second scrolling view is the height of the display screen, when the total of the loaded cells is higher than the height of the display screen, the cells can be reused through the tableview without further increasing the memory.
[0054] The technical solution of the embodiment of the present invention can obtain the initial margin and the first offset of the first scroll view corresponding to the trigger event by monitoring the trigger event of controlling the scroll view; then, according to the numerical relationship between the first offset and the initial margin, the scroll parameter of the second scroll view can be determined, and the scrolling of the second scroll view can be controlled according to the scroll parameter. The above technical solution solves the problem of gesture conflicts in nested scroll views, and the effect of scrolling control of the second scroll view can be achieved through the first scroll view.
[0055] Embodiment 2
[0056] Figure 3 It is a flow chart of a scroll view control method provided in the second embodiment of the present invention. This embodiment is optimized based on the above technical solutions. In this embodiment, optionally, the scrollable range of the first scroll view in the scrolling direction is the sum of the scrollable range of the second scroll view in the scrolling direction and the initial margin. Among them, the explanations of the terms that are the same or corresponding to the above embodiments are not repeated here.
[0057] See also Figure 3 The method of this embodiment may specifically include the following steps:
[0058] S210. When a triggering event for controlling a scrolling view is monitored, an initial margin and a first offset of the first scrolling view corresponding to the triggering event are obtained, wherein the initial margin is a margin of the second scrolling view relative to the first scrolling view in a scrolling direction of the second scrolling view, and the scrollable range of the first scrolling view in the scrolling direction is the sum of the scrollable range of the second scrolling view in the scrolling direction and the initial margin.
[0059] Wherein, the scrollable range may include a scrollable width and a scrollable height, and the initial margin may be an initial width or an initial height. Thus, if the scrolling direction is a vertical direction, the scrollable height of the first scroll view is the sum of the scrollable height and the initial height of the second scroll view. For example, when the initial margin is scrollViewTopPadding, the first scroll view is mainScrollView, and the second scroll view is contentScrollView, mainScrollView.contentSize.height = contentScrollView.contentSize.height + scrollViewTopPadding. At this time, the lower boundary of the first scroll view coincides with the lower boundary of the second scroll view, or the upper boundary of the first scroll view coincides with the upper boundary of the second scroll view. If the scrolling direction is a horizontal direction, the scrollable width of the first scroll view is the sum of the scrollable width and the initial margin of the second scroll view, that is, mainScrollView.contentSize.width = contentScrollView.contentSize.width + scrollViewTopPadding. At this time, the left boundary of the first scroll view coincides with the left boundary of the second scroll view, or the right boundary of the first scroll view coincides with the right boundary of the second scroll view.
[0060] S220: Determine a scrolling parameter of the second scrolling view according to the first offset and the initial margin, and control the second scrolling view to scroll according to the scrolling parameter.
[0061] On this basis, optionally, if the first offset is greater than the initial margin, this indicates that the second scroll view needs to scroll, and the target margin of the second scroll view can be set to the first offset, and the second offset of the second scroll view can be set to the difference between the first offset and the initial margin. Optionally, if the first offset is less than the initial margin, this indicates that the first scroll view needs to scroll, and the target margin of the second scroll view can be set to the initial margin, and the second offset of the second scroll view can be set to 0. As can be seen from the above, the second content view is completely scrolled by the first scroll view. Therefore, there is no need to involve the second offset of the second scroll view, which is controlled by the first offset of the first scroll view.
[0062] According to the technical solution of the embodiment of the present invention, the scrolling of the second scrolling view and the second content view is completely controlled by the first scrolling view. Specifically, when the second scrolling view needs to scroll, the target margin (a value in the frame) of the second scrolling view is set to make it scroll in the opposite direction of the scrolling gesture, and the second offset is set according to the scrolling gesture. In this way, visually, the second scrolling view does not scroll, and the second content view scrolls in the direction of the scrolling gesture; when the first scrolling view needs to scroll, the target margin of the second scrolling view is set to return to the initial position.
[0063] In order to better understand the specific implementation process of the above steps, the target detection method of this embodiment is exemplarily described below in combination with specific examples. Exemplarily, create a view controller viewController and add a delegate UIScrollViewDelegate; add two UIScrollView type pointer variables mainScrollView and contentScrollView and a floating-point type variable scrollViewTopPadding in viewController, where mainScrollView is the first scroll view and contentScrollView is the second scroll view; instantiate mainScrollView and contentScrollView, add contentScrollView to mainScrollView, set the delegate of mainScrollView to viewController, assign the initial height contentScrollView.frame.origin.y between the upper boundary of contentScrollView and the upper boundary of mainScrollView to scrollViewTopPadding; set mainScrollView.contentSize.height = contentScrollView.contentSize.height + scrollViewTopPadding; add scrollViewDidScroll:(UIScrollView*)scrollView delegate method in viewController, add CGRect type variable frame in the scrollViewDidScroll method, and assign it to conentScrollView.frame, so that frame.origin.y = scrollViewTopPadding. Add a CGPoint type variable offset in the scrollViewDidScroll method and assign it to tableView.contentOffset (ie, offset = tableView.contentOffset) so that offset.y = mainScrollView.contentOffset.y - scrollViewTopPadding.
[0064] If offset.y is less than 0, this means that mainScrollView needs to scroll, set the target margin of contentScrollView to the initial height (i.e., frame.origin.y = scrollViewTopPadding), and set the second offset of contentScrollView to 0 (i.e., conentScrollView.contentOffset = 0); if offset.y is greater than 0, this means that contentScrollView needs to scroll, set the target margin of contentScrollView to the first offset of mainScrollView (i.e., frame.origin.y = mainScrollView.contentOffset.y), and set the second offset of contentScrollView to the first offset - initial height (i.e., conentScrollView.contentOffset = offset.y).
[0065] In order to describe the above scrolling process more vividly, the scrolling view control method of this embodiment is exemplarily described below by taking the first scrolling view being a large photo frame and the first content view being a large photo in the large photo frame, and the second scrolling view being a small photo frame and the second content view being a small photo in the small photo frame as an example.
[0066] Exemplarily, the small photo frame and the small photo are both set on the large photo, and they can move synchronously with the movement of the large photo. At the initial moment, the lower boundaries of the large photo frame and the small photo frame overlap, and the first offset is less than the initial height. Figure 4a When an upward scrolling gesture is detected, the small photo frame and the small photo scroll upward synchronously with the large photo, as shown in FIG. Figure 4b As shown, the first offset gradually increases; in the process of scrolling upward, when the upper boundary of the large photo frame coincides with the upper boundary of the small photo frame, the first offset is equal to the initial margin, as shown in FIG. Figure 4c As shown; the scrolling gesture is still scrolling upward. At this time, the first offset is greater than the initial margin. The large photo continues to scroll upward, and the small photo will continue to scroll upward with the large photo. In particular, in order to ensure that the small photo frame does not exceed its scrollable range, the small photo frame and the large photo frame remain relatively stationary, that is, the small photo frame scrolls downward, thereby preventing the large photo from driving the small photo frame out of the large photo frame. Figure 4dAs shown. When a scrolling gesture of scrolling down is detected, the first offset at this time is greater than the initial height, the small photo scrolls down synchronously with the large photo, and the small photo frame and the large frame remain relatively motionless until the upper boundary of the small photo coincides with the upper boundary of the small photo frame, and the first offset at this time is equal to the initial height; the scrolling gesture is still scrolling down, and the first offset at this time is less than the initial margin, and the small photo frame and the small photo slide down synchronously with the large photo. It can be seen that during the scrolling process, the large photo and the small photo are always in a synchronous scrolling state; when the first offset is less than the initial height, the large photo and the small photo frame are always in a synchronous scrolling state; when the first offset is greater than the initial height, the large photo does not drive the small photo frame to scroll, and the large and small frames and the small photo frame remain relatively motionless.
[0067] Embodiment 3
[0068] Figure 5 This is a structural block diagram of a scroll view control device provided in Embodiment 3 of the present invention, and the device is used to execute the scroll view control method provided in any of the above embodiments. The device and the scroll view control method of the above embodiments belong to the same inventive concept, and the details not described in detail in the embodiment of the scroll view control device can refer to the embodiment of the above scroll view control method. Figure 5 The device can be configured in a view controller, in which a first scroll view and a second scroll view nested in the first scroll view are provided. The device can specifically include: a first offset acquisition module 310 and a scroll view control module 320. Among them,
[0069] A first offset acquisition module 310 is used to acquire an initial margin and a first offset of the first scrolling view corresponding to the triggering event when a triggering event for controlling the scrolling view is detected, wherein the initial margin is a margin of the second scrolling view relative to the first scrolling view in a scrolling direction of the second scrolling view;
[0070] The scroll view control module 320 is used to determine the scroll parameter of the second scroll view according to the first offset and the initial margin, and control the second scroll view to scroll according to the scroll parameter.
[0071] Optionally, the scrollable range of the first scroll view in the scrolling direction is the sum of the scrollable range of the second scroll view in the scrolling direction and the initial margin.
[0072] Optionally, the scroll view control module 320 may specifically include:
[0073] The first scroll parameter determination unit is configured to set the target margin of the second scroll view to the first offset if the first offset is greater than the initial margin, and set the second offset of the second scroll view to the difference between the first offset and the initial margin.
[0074] Optionally, the scroll view control module 320 may specifically include:
[0075] The second scroll parameter determining unit is configured to set the target margin of the second scroll view to the initial margin and set the second offset of the second scroll view to 0 if the first offset is smaller than the initial margin.
[0076] Optionally, the scroll view control module 320 may specifically include:
[0077] The second scroll view control unit is used to control the second scroll view to scroll according to the target margin, and to control the second content view set in the second scroll view to scroll according to the second offset.
[0078] Optionally, based on the above device, the device may further include:
[0079] The first scroll view control module is used to control the scrolling of the first content view set in the first scroll view according to the first offset.
[0080] Optionally, the first offset acquisition module 310 may specifically include:
[0081] A sending unit, wherein the agent of the first scroll view is a view controller, and sends a trigger event to the first scroll view corresponding to the agent, so that the first scroll view triggers a preset notification function according to the trigger event;
[0082] The obtaining unit is used to obtain a first offset of the first scroll view according to a preset notification function.
[0083] The scrolling view control device provided in the third embodiment of the present invention can obtain the initial margin and the first offset of the first scrolling view corresponding to the triggering event through the first offset acquisition module when monitoring the triggering event of controlling the scrolling view; further, the scrolling view control module can determine the scrolling parameters of the second scrolling view according to the numerical relationship between the first offset and the initial margin, and control the scrolling of the second scrolling view according to the scrolling parameters. The above device solves the problem of gesture conflicts in mutually nested scrolling views, and the effect of scrolling control of the second scrolling view can be achieved through the first scrolling view.
[0084] The scroll view control device provided in the embodiment of the present invention can execute the scroll view control method provided in any embodiment of the present invention, and has the corresponding functional modules and beneficial effects of the execution method.
[0085] It is worth noting that in the embodiment of the above-mentioned scrolling view control device, the various units and modules included are only divided according to functional logic, but are not limited to the above-mentioned division, as long as the corresponding functions can be achieved; in addition, the specific names of the functional units are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of the present invention.
[0086] Embodiment 4
[0087] Figure 6 A schematic diagram of a device structure provided in Embodiment 4 of the present invention is shown in FIG. Figure 6 As shown, the device includes a memory 410, a processor 420, an input device 430, and an output device 440. The number of processors 420 in the device can be one or more. Figure 6 A processor 420 is used as an example; the memory 410, the processor 420, the input device 430 and the output device 440 in the device can be connected via a bus or other means. Figure 6 The connection via bus 450 is taken as an example.
[0088] The memory 410, as a computer-readable storage medium, can be used to store software programs, computer executable programs and modules, such as program instructions / modules corresponding to the scroll view control method in the embodiment of the present invention (for example, the first offset acquisition module 310 and the scroll view control module 320 in the scroll view control device). The processor 420 executes various functional applications and data processing of the device by running the software programs, instructions and modules stored in the memory 410, that is, realizing the above-mentioned scroll view control method.
[0089] The memory 410 may mainly include a program storage area and a data storage area, wherein the program storage area may store an operating system and at least one application required for a function; the data storage area may store data created according to the use of the device, etc. In addition, the memory 410 may include a high-speed random access memory, and may also include a non-volatile memory, such as at least one disk storage device, a flash memory device, or other non-volatile solid-state storage device. In some instances, the memory 410 may further include a memory remotely arranged relative to the processor 420, and these remote memories may be connected to the device via a network. Examples of the above-mentioned network include, but are not limited to, the Internet, an intranet, a local area network, a mobile communication network, and combinations thereof.
[0090] The input device 430 may be used to receive input digital or character information and generate key signal input related to user settings and function control of the device. The output device 440 may include a display device such as a display screen.
[0091] Embodiment 5
[0092] Embodiment 5 of the present invention provides a storage medium including computer executable instructions. When the computer executable instructions are executed by a computer processor, they are used to execute a scroll view control method. The method is applied to a view controller. A first scroll view and a second scroll view nested in the first scroll view are provided in the view controller. The method may include:
[0093] When a trigger event for controlling a scroll view is detected, an initial margin and a first offset of the first scroll view corresponding to the trigger event are obtained, wherein the initial margin is a margin of the second scroll view relative to the first scroll view in a scrolling direction of the second scroll view;
[0094] According to the first offset and the initial margin, a scrolling parameter of the second scrolling view is determined, and the second scrolling view is controlled to scroll according to the scrolling parameter.
[0095] Of course, the computer executable instructions of a storage medium including computer executable instructions provided by an embodiment of the present invention are not limited to the operations of the method described above, and can also execute related operations in the scroll view control method provided by any embodiment of the present invention.
[0096] Through the above description of the implementation methods, the technicians in the relevant field can clearly understand that the present invention can be implemented by means of software and necessary general hardware, and of course it can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as a computer floppy disk, read-only memory (ROM), random access memory (RAM), flash memory (FLASH), hard disk or optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, server, or network device, etc.) to execute the methods described in each embodiment of the present invention.
[0097] Note that the above are only preferred embodiments of the present invention and the technical principles used. Those skilled in the art will understand that the present invention is not limited to the specific embodiments described herein, and that various obvious changes, readjustments and substitutions can be made by those skilled in the art without departing from the scope of protection of the present invention. Therefore, although the present invention has been described in more detail through the above embodiments, the present invention is not limited to the above embodiments, and may include more other equivalent embodiments without departing from the concept of the present invention, and the scope of the present invention is determined by the scope of the appended claims.
Claims
1. A scroll view control method, characterized in that: Applied to a view controller, wherein a first scroll view and a second scroll view nested in the first scroll view are provided in the view controller, the method comprising: When a trigger event for controlling a scroll view is detected, an initial margin and a first offset of the first scroll view corresponding to the trigger event are obtained, wherein the initial margin is a margin of the second scroll view relative to the first scroll view in a scrolling direction of the second scroll view, and the first offset represents a positional relationship between a first content view set in the first scroll view and the first scroll view, and the first content view and the second content view set in the second scroll view are always scrolled synchronously; According to the first offset and the initial margin, a scrolling parameter of the second scrolling view is determined, and the second scrolling view is controlled to scroll according to the scrolling parameter.
2. The method according to claim 1, characterized in that The scrollable range of the first scroll view in the scroll direction is the sum of the scrollable range of the second scroll view in the scroll direction and the initial margin.
3. The method according to claim 2, characterized in that The step of determining the scrolling parameter of the second scrolling view according to the first offset and the initial margin includes: If the first offset is greater than the initial margin, the target margin of the second scroll view is set to the first offset, and the second offset of the second scroll view is set to the difference between the first offset and the initial margin.
4. The method according to claim 2, characterized in that: The step of determining the scrolling parameter of the second scrolling view according to the first offset and the initial margin includes: If the first offset is smaller than the initial margin, the target margin of the second scroll view is set to the initial margin, and the second offset of the second scroll view is set to 0.
5. The method according to claim 1, characterized in that: The scrolling parameters include a second offset and a target margin, and controlling the second scrolling view to scroll according to the scrolling parameters includes: The second scroll view is controlled to scroll according to the target margin, and the second content view set in the second scroll view is controlled to scroll according to the second offset.
6. The method according to claim 1, characterized in that Also includes: The first content view set in the first scroll view is controlled to scroll according to the first offset.
7. The method according to claim 1, characterized in that The delegate of the first scroll view is the view controller; The acquiring a first offset of the first scroll view corresponding to the trigger event includes: Sending the trigger event to the first scroll view corresponding to the agent, so that the first scroll view triggers a preset notification function according to the trigger event; A first offset of the first scroll view is obtained according to the preset notification function.
8. A scroll view control device, characterized in that: The apparatus is configured in a view controller, wherein a first scroll view and a second scroll view nested in the first scroll view are provided in the view controller, and the apparatus comprises: a first offset acquisition module, configured to acquire an initial margin and a first offset of the first scrolling view corresponding to the triggering event when a triggering event for controlling a scrolling view is detected, wherein the initial margin is a margin of the second scrolling view relative to the first scrolling view in a scrolling direction of the second scrolling view, and the first offset represents a positional relationship between a first content view set in the first scrolling view and the first scrolling view, and the first content view and the second content view set in the second scrolling view always scroll synchronously; The scroll view control module is used to determine the scroll parameter of the second scroll view according to the first offset and the initial margin, and control the second scroll view to scroll according to the scroll parameter.
9. A device, characterized in that: The device comprises: one or more processors; A memory for storing one or more programs; When the one or more programs are executed by the one or more processors, the one or more processors implement the scroll view control method as described in any one of claims 1 to 7.
10. A computer-readable storage medium having a computer program stored thereon, characterized in that: When the computer program is executed by a processor, the scroll view control method according to any one of claims 1 to 7 is implemented.
Citation Information
Patent Citations
Sliding view display method and device and mobile terminal
CN110568974A