yyl
2 天以前 5d3366f2e0f687995eb7ad2107c4379fe7acd4e8
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using UnityEngine;
using System.Collections;
 
namespace EnhancedUI.EnhancedScroller
{
    /// <summary>
    /// All scripts that handle the scroller's callbacks should inherit from this interface
    /// </summary>
    public interface IEnhancedScrollerDelegate
    {
        /// <summary>
        /// Gets the number of cells in a list of data
        /// </summary>
        /// <param name="scroller"></param>
        /// <returns></returns>
        int GetNumberOfCells(EnhancedScroller scroller);//得到Scroll里面CellVeiw的总数目
 
        /// <summary>
        /// Gets the size of a cell view given the index of the data set.
        /// This allows you to have different sized cells
        /// </summary>
        /// <param name="scroller"></param>
        /// <param name="dataIndex"></param>
        /// <returns></returns>
        float GetCellViewSize(EnhancedScroller scroller, int dataIndex);//得到某个dataIndex的size(因为有可能会存在不同的CellVeiw)
 
        /// <summary>
        /// Gets the cell view that should be used for the data index. Your implementation
        /// of this function should request a new cell from the scroller so that it can
        /// properly recycle old cells.
        /// </summary>
        /// <param name="scroller"></param>
        /// <param name="dataIndex"></param>
        /// <param name="cellIndex"></param>
        /// <returns></returns>
        EnhancedScrollerCellView GetCellView(EnhancedScroller scroller, int dataIndex, int cellIndex);
        /*
         * 用于得到(或从循环集合中取,或实例化)一个CellView并取其CellView对象
           注意这里返回的是CellView的父类型,CellVeiw是要自己来写的,这样就可以通过重写父类的虚方法实现多态
           */
 
 
        /*要想使用这个插件,需要我们添加两个类,
         * 1)一个类继承自EnHancedScrollerCellView,用于保存单个CellView的相关信息
         * 2)另一个类实现这个接口,用于控制整个Scroll,并提供给外界一些相关信息(总的CellView数目,每个CellView的size等)
         *      其中,GetCellView()方法在实现的时候直接调用 EnhancedScroller类中的GetCellView()方法来进行实现就可以了
         * 这两个类也可根据自己的需要进行扩展
         */
 
 
        void OnRebuildComplete();
    }
}