单击时,收藏夹视图单元格向左移动

时间:2019-12-07 06:57:08

标签: uicollectionview uicollectionviewcell

我正在使用collectionview cell,应用正在运行阿拉伯语和英语。当应用程序以英语运行时,单元格向左滚动,阿拉伯语应用程序向右滚动。

//MARK:- UICollectionview Delegate and Datasource

func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -> Int{

        if collectionView == Collection_Slide {
            return arr_banner.count
        }else{
            return arr_Category.count
        }
    }

    func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -> UICollectionViewCell {
        if collectionView == Collection_Slide {

            let cell : SlideImageCollection_Cell? = collectionView.dequeueReusableCell(withReuseIdentifier: "SlideImageCollection_Cell", for: indexPath) as? SlideImageCollection_Cell

            if let dict_shop = arr_banner.object(at: indexPath.row) as? NSDictionary {
                if let banarImg = dict_shop.value(forKey: "image") as? String {

                    let path = "assets/image_uploads/home_page_slider/"

                    let img_url = KAPIIMAGEURL + path + banarImg
                    let urlwithPercentEscapes = img_url.addingPercentEncoding( withAllowedCharacters: .urlQueryAllowed)

                    cell?.activity.startAnimating()
                    cell?.img_slides.sd_setImage(with: URL(string: urlwithPercentEscapes!), placeholderImage: UIImage(named: ""), options: []) { (image, error, imageCacheType, imageUrl) in

                        // Perform your operations here.
                        cell?.img_slides.autoresizingMask = [.flexibleWidth, .flexibleHeight, .flexibleBottomMargin, .flexibleRightMargin, .flexibleLeftMargin, .flexibleTopMargin]
                        cell?.img_slides.contentMode = .scaleAspectFill
                        cell?.img_slides.clipsToBounds = true
                        cell?.activity.stopAnimating()
                    }
                }
            }
            return cell!
        }
        else{

            let cell : ShopProductCat_Cell? = collectionView.dequeueReusableCell(withReuseIdentifier: "ShopProductCat_Cell", for: indexPath) as? ShopProductCat_Cell

            cell?.lbl_Devider.isHidden = true

            if slected_theme.contains(indexPath.row) {
                cell?.lbl_Devider.isHidden = false
                cell?.lbl_title.textColor = UIColor.init(red: 85.0/255.0, green: 49.0/255.0, blue: 133.0/255.0, alpha: 1)
            }
            else{
                cell?.lbl_Devider.isHidden = true
                cell?.lbl_title.textColor = .white
            }
            if let dict_cat = arr_Category.object(at: indexPath.row) as? NSDictionary{
                if let catName = dict_cat.value(forKey: "cat_name") as? String {
                    cell?.lbl_title.text = catName
                }
            }

            return cell!
        }
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath) -> CGSize {

        if collectionView == Collection_Slide {
            let size:CGSize = CGSize(width: Constants.WIDTH, height: 221)
            return size
        }
        else {
            let size:CGSize = CGSize(width: 101, height: 44)
            return size
        }
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, insetForSectionAt section: Int) -> UIEdgeInsets {
        if collectionView == Collection_Slide {
            return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        }
        else {
            return UIEdgeInsets(top: 0, left: 0, bottom: 0, right: 0)
        }
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumInteritemSpacingForSectionAt section: Int) -> CGFloat {
        return 0.0
    }
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, minimumLineSpacingForSectionAt section: Int) -> CGFloat {
        return 0.0
    }

这里是图像和视频。

http://prntscr.com/q7fsjf

https://drive.google.com/file/d/11YiM9a9e85jYBhQtT1UlUGaJfEflYocb/view?usp=sharing

0 个答案:

没有答案