Git Product home page Git Product logo

Comments (7)

LvJianfeng avatar LvJianfeng commented on August 17, 2024

@623034345 Demo有的呢。

let bannerDemo = LLCycleScrollView.llCycleScrollViewWithFrame(CGRect.init(x: 0, y: titleDemo.ll_y + 80, width: w, height: 200), imageURLPaths: imagesURLStrings, titles:titles, didSelectItemAtIndex: { index in
    print("当前点击图片的位置为:\(index)")
})

from llcyclescrollview.

623034345 avatar 623034345 commented on August 17, 2024

只能初始化的时候用吗? 能单独调用吗? 刚学Swift 对block不熟悉0.0

from llcyclescrollview.

LvJianfeng avatar LvJianfeng commented on August 17, 2024

@623034345 这边我写初始化的时候给闭包赋值呢,点击才回调呢。如果没实现闭包,就没有回调的。

from llcyclescrollview.

623034345 avatar 623034345 commented on August 17, 2024

哦,谢谢了

from llcyclescrollview.

bugaco avatar bugaco commented on August 17, 2024

也可以在初始化之后调用,如下:

  1. 声明一个回掉方法:
    func llDidSelectItemAtIndex(index: Int){
        print("轮播图的第\(index)项被点击了")
    }
  1. 赋值
bannerDemo.lldidSelectItemAtIndex = llDidSelectItemAtIndex(index:)

from llcyclescrollview.

LvJianfeng avatar LvJianfeng commented on August 17, 2024

@zanyzephyr 不用这么麻烦呢,实现代码逻辑较多,可以在回调里面去调用你声明的方法呢。

bannerDemo.lldidSelectItemAtIndex = { index in
    tapAction(index)
}
或者直接在初始化的时候去调用

let bannerDemo = LLCycleScrollView.llCycleScrollViewWithFrame(CGRect, imageURLPaths: imagesURLStrings, didSelectItemAtIndex: { index in
    tapAction(index)
})


func tapAction(_ index: Int) {
    // Action Code
}

from llcyclescrollview.

bugaco avatar bugaco commented on August 17, 2024

@LvJianfeng 第一种写法简洁了好多👍

from llcyclescrollview.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.