如何在当前情况下滚动数组?

时间:2016-04-14 04:10:24

标签: ios arrays swift

我有一个字符串数组,我想设置它们,因此用户可以滚动字符串,并且选择了哪一个字符串,但我不确定如何操作。我正在考虑使用滚动视图或pagevc,但这些视图占据整个视图,并且每页显示一个字符串。相反,我需要它们并排,所以我可以看到前方或后方的价值。关于如何执行此操作的路线图将是完美的,我在这个组件上迷失了方向。 How scrolling through should look like

func numberOfItemsInCarousel(carousel: iCarousel) -> Int {
    //getInfo()

     return animal.count
}

func carousel(carousel: iCarousel, viewForItemAtIndex index: Int, reusingView view: UIView?) -> UIView {
    var labelsubject: UILabel
    var itemView: UIImageView
    var labelname: UILabel
    var cardimage: UIImageView
    var cardtypeimage: UIImageView

    if(view == nil){
        itemView = UIImageView(frame:CGRect(x:0, y:0, width:400, height:100))
        itemView.image = UIImage(named: "page")
        itemView.contentMode = .Center

        labelsubject = UILabel(frame: itemView.bounds)
        labelsubject.backgroundColor = UIColor.clearColor()
        labelsubject.textAlignment = .Center
        labelsubject.textColor = UIColor.whiteColor()
        labelsubject.tag = 1
        itemView.addSubview(labelsubject)

    }else{
        itemView = view as! UIImageView;
        labelsubject = itemView.viewWithTag(1) as! UILabel!

    }

    selectedData.anim = animal[index]
        return itemView



}

func carouselDidEndDragging(carousel: iCarousel, willDecelerate decelerate: Bool) {

    if !decelerate {
        print(carousel.currentItemIndex)
        //text[carousel.currentItemIndex]
    }
}

func carouselDidEndDecelerating(carousel: iCarousel) {
    print(carousel.currentItemIndex)
    //text[carousel.currentItemIndex]
}

0 个答案:

没有答案