在UICollectionView滚动一定距离后调用函数Objective-C

时间:2017-01-30 04:46:28

标签: ios objective-c uiscrollview uicollectionview uicollectionviewcell

我正在尝试创建一个仅在CollectionView滚动或拖动一定距离后调用的函数,并且每次滚动距离时都会重复调用该函数。

我还需要在加载CollectionView之后最初调用此函数。我怎样才能为Objective-C iOS应用程序实现此目的?

2 个答案:

答案 0 :(得分:0)

<project basedir="." default="build" name="Calculator">
    <property environment="env"/>
    <property name="junit.output.dir" value="junit"/>
    <property name="debuglevel" value="source,lines,vars"/>
    <property name="target" value="1.8"/>
    <property name="source" value="1.8"/>
    <path id="JUnit 4.libraryclasspath">
        <pathelement location="../../../.p2/pool/plugins/org.junit_4.12.0.v201504281640/junit.jar"/>
        <pathelement location="../../../.p2/pool/plugins/org.hamcrest.core_1.3.0.v201303031735.jar"/>
    </path>
    <path id="Calculator.classpath">
        <pathelement location="bin"/>
        <path refid="JUnit 4.libraryclasspath"/>
    </path>
    <target name="init">
        <mkdir dir="bin"/>
        <copy includeemptydirs="false" todir="bin">
            <fileset dir="src">
                <exclude name="**/*.launch"/>
                <exclude name="**/*.java"/>
            </fileset>
        </copy>
    </target>
    <target name="clean">
        <delete dir="bin"/>
    </target>
    <target depends="clean" name="cleanall"/>
    <target depends="build-subprojects,build-project" name="build"/>
    <target name="build-subprojects"/>
    <target depends="init" name="build-project">
        <echo message="${ant.project.name}: ${ant.file}"/>
        <javac debug="true" debuglevel="${debuglevel}" destdir="bin" includeantruntime="false" source="${source}" target="${target}">
            <src path="src"/>
            <classpath refid="Calculator.classpath"/>
        </javac>
    </target>
    <target description="Build all projects which reference this project. Useful to propagate changes." name="build-refprojects"/>
    <target description="copy Eclipse compiler jars to ant lib directory" name="init-eclipse-compiler">
        <copy todir="${ant.library.dir}">
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </copy>
        <unzip dest="${ant.library.dir}">
            <patternset includes="jdtCompilerAdapter.jar"/>
            <fileset dir="${ECLIPSE_HOME}/plugins" includes="org.eclipse.jdt.core_*.jar"/>
        </unzip>
    </target>
    <target description="compile project with Eclipse compiler" name="build-eclipse-compiler">
        <property name="build.compiler" value="org.eclipse.jdt.core.JDTCompilerAdapter"/>
        <antcall target="build"/>
    </target>
    <target name="AllTests">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.AllTests" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="AdditionTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.AdditionTest" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="Divide">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.Divide" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="Multiply">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.Multiply" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="SubtractTest">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.SubtractTest" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="AllTestss">
        <mkdir dir="${junit.output.dir}"/>
        <junit fork="yes" printsummary="withOutAndErr">
            <formatter type="xml"/>
            <test name="CalculatorProject.AllTestss" todir="${junit.output.dir}"/>
            <jvmarg line="-ea"/>
            <classpath refid="Calculator.classpath"/>
        </junit>
    </target>
    <target name="junitreport">
        <junitreport todir="${junit.output.dir}">
            <fileset dir="${junit.output.dir}">
                <include name="TEST-*.xml"/>
            </fileset>
            <report format="frames" todir="${junit.output.dir}"/>
        </junitreport>
    </target>
</project>

答案 1 :(得分:0)

- (void)scrollViewDidEndDragging:(UIScrollView *)scrollView willDecelerate:(BOOL)decelerate {
    NSLog(@"%f %f", self.tableView.contentOffset.x, self.tableView.contentOffset.y);
}

我想你需要这个。