Post

Replies

Boosts

Views

Activity

Reply to Static Func not calling variable
it gives an errorstatic func LoginGenerateToken(userName: String, password: String) { let parameters = LoginGenerateTokenStruct(userName: userName, password: password.sha256()) LoginSingleton.shared.mailUserLogin = userName networkManager1 = URL_Session() networkManager1?.delegate = self networkManager1?.LoginGenerateTokenPOST(parameters: parameters) }because networkManager1it's outside the function i should declare like this publicstaticfunc LoginGenerateToken(userName: String, password: String) { var networkManager1: URL_Session? let parameters = LoginGenerateTokenStruct(userName: userName, password: password.sha256()) LoginSingleton.shared.mailUserLogin = userName networkManager1 = URL_Session() networkManager1?.delegate = self networkManager1?.LoginGenerateTokenPOST(parameters: parameters) }but i cant use the delegate method if i do it this way
Nov ’19
Reply to Expanding Table View Cells index out of range
thanks i follow your advice and change the names this is the print result:Section 0tableViewData 2tableViewDataInside 1Section 1tableViewData 2tableViewDataInside 1Fatal error: Index out of rangeit crash in line 131 check the code bellow ⬇this is the code, i remove almost all coments i just notice something my IF stament is not working in didSelectRowAti want to expande the table only if the user select certain row not every indexpath.row == 2if indexPath.row == 2 && tableViewData[indexPath.section].sectionData == ["1.2"] {what im doing wrong?import UIKit class TableSupportVC: UITableViewController { let interface: TableSupportView = { let interface = TableSupportView(frame: CGRect.zero) interface.translatesAutoresizingMaskIntoConstraints = false return interface }() struct CellData { var opened = Bool() var title = String() var sectionData = [String]() } struct DataInside { var opened = Bool() var title = String() var sectionData = [String]() } var tableViewData = [CellData]() var tableViewDataInside = [DataInside]() override func viewDidLoad() { super.viewDidLoad() tableView.register(TableSupportCell.self, forCellReuseIdentifier: menuCellIdita) tableView.register(TableSupportSubtitleCell.self, forCellReuseIdentifier: menuCellda) //CellData tableViewData = [CellData(opened: false, title: "1", sectionData: ["1.1", "1.2","1.3","1.4"]), CellData(opened: false, title: "2", sectionData: ["2.1", "2.2", "2.3"]) ] //DataInside tableViewDataInside = [DataInside(opened: false, title: "1.1.1", sectionData: ["1.1.1"])] setThemeNavigationBar() // Size Scrollview interface.scrollView.contentSize = CGSize(width: wScreen, height: hScreen * 1.40) initComponents() } func setThemeNavigationBar() { let navigationBarAppearace = UINavigationBar.appearance() navigationBarAppearace.tintColor = blueBlumon navigationBarAppearace.barTintColor = blueBlumon navigationController?.navigationBar.barTintColor = blueBlumon navigationController?.navigationBar.barStyle = .blackOpaque navigationController?.navigationBar.isTranslucent = false } private func initComponents() { setNavItems() setSubviews() setAutolayout() } private func setSubviews() { view.backgroundColor = UIColor.white view.addSubview(interface) } private func setNavItems() { let backIcon = UIImage(named: "whiteArrow") let backItem = UIBarButtonItem(image: backIcon?.withRenderingMode(.alwaysTemplate), style: UIBarButtonItem.Style.plain, target: self, action: #selector(backPressed)) backItem.tintColor = UIColor.white navigationItem.leftBarButtonItem = backItem let logoIcon = UIImage(named: "itemLogoBlue") let logoItem = UIBarButtonItem(image: logoIcon?.withRenderingMode(.alwaysOriginal), style: UIBarButtonItem.Style.plain, target: nil, action: nil) navigationItem.rightBarButtonItem = logoItem } // Método para definir el autolayout de los componentes de la vista principal del controlador private func setAutolayout() { NSLayoutConstraint.activate([ interface.topAnchor.constraint(equalTo: view.safeAreaLayoutGuide.topAnchor), interface.trailingAnchor.constraint(equalTo: view.trailingAnchor), interface.bottomAnchor.constraint(equalTo: view.safeAreaLayoutGuide.bottomAnchor), interface.leadingAnchor.constraint(equalTo: view.leadingAnchor) ]) } // Método de selector backPressed @objc private func backPressed() { self.navigationController?.popViewController(animated: true) dismiss(animated: true, completion: nil) } // MARK: - Table view data source override func numberOfSections(in tableView: UITableView) -> Int { return tableViewData.count } override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { print("Section", section) print("tableViewData", tableViewData.count) print("tableViewDataInside", tableViewDataInside.count) if tableViewData[section].opened == true { return tableViewData[section].sectionData.count + 1 } //**//INDEX OUT OF RANGE HERE** if tableViewDataInside[section].opened == true{ return tableViewDataInside[section].sectionData.count + 1 } else { return 1 } } override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { if indexPath.row == 0{ let cell = tableView.dequeueReusableCell(withIdentifier: menuCellIdita, for: indexPath) as! TableSupportCell cell.optionTitle.text = tableViewData[indexPath.section].title return cell } if indexPath.row == 2 && tableViewData[indexPath.section].sectionData == ["1.2"]{ let cell = tableView.dequeueReusableCell(withIdentifier: menuCellda, for: indexPath) as! TableSupportSubtitleCell cell.title.text = tableViewDataInside[indexPath.section].title return cell } else { let cell = tableView.dequeueReusableCell(withIdentifier: menuCellIdita, for: indexPath) as! TableSupportCell cell.optionTitle.text = tableViewData[indexPath.section].sectionData[indexPath.row - 1] return cell } } override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { print("el indexpath es: \(indexPath.row)") if indexPath.row == 0 { print("seleccionó 0") if tableViewData[indexPath.section].opened == true{ tableViewData[indexPath.section].opened = false let sections = IndexSet.init(integer: indexPath.section) tableView.reloadSections(sections, with: .none) } else{ tableViewData[indexPath.section].opened = true let sections = IndexSet.init(integer: indexPath.section) tableView.reloadSections(sections, with: .none) } } if indexPath.row == 2 && tableViewData[indexPath.section].sectionData == ["1.2"] { print("seleccionó 1.2") if tableViewDataInside[indexPath.section].opened == true{ tableViewDataInside[indexPath.section].opened = false let sections = IndexSet.init(integer: indexPath.section) tableView.reloadSections(sections, with: .none) } else{ tableViewDataInside[indexPath.section].opened = true let sections = IndexSet.init(integer: indexPath.section) tableView.reloadSections(sections, with: .none) } } } override func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat { return 80 } func checkItemCount(arr: [String]) { var dict = [String: Any]() for x in arr { var count = 0 for y in arr { if y == x { count += 1 } } dict[x] = count } print(dict) } }
Mar ’20
Reply to Expanding Table View Cells index out of range
Thanks for the helpthe difference between: tableViewData and tableViewDataInsideis the constraints.Here's the class of tableViewDatathis UITableViewCell class should display a message covert all the cell with 90% of heigh and 90% of width of the cellwith only 1 Labelimport UIKit let menuCellIdita = "celldita" class TableSupportCell: UITableViewCell { var optionTitle: UILabel = { let optionTitle = UILabel() optionTitle.font = UIFont(name: "Helvetica-bold", size: 14) optionTitle.textAlignment = .justified optionTitle.text = "label example" optionTitle.adjustsFontSizeToFitWidth = true optionTitle.textColor = blueMifel optionTitle.translatesAutoresizingMaskIntoConstraints = false optionTitle.backgroundColor = UIColor.clear optionTitle.numberOfLines = 0 return optionTitle }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) addSubview(optionTitle) // addSubview(iconImage) setAutoLayout() self.backgroundColor = UIColor.clear } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setAutoLayout() { NSLayoutConstraint.activate([ optionTitle.centerXAnchor.constraint(equalTo: self.centerXAnchor), optionTitle.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.90), optionTitle.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 0.90), optionTitle.centerYAnchor.constraint(equalTo: self.centerYAnchor) ]) } }here's the class for tableViewDataInsideimport UIKit let menuCellda = "cellditaSub" class TableSupportSubtitleCell: UITableViewCell { var title: UILabel = { let optionTitle = UILabel() optionTitle.font = UIFont(name: "Helvetica-bold", size: 14) optionTitle.textAlignment = .justified optionTitle.text = "label example" optionTitle.adjustsFontSizeToFitWidth = true optionTitle.textColor = blueMifel optionTitle.translatesAutoresizingMaskIntoConstraints = false optionTitle.backgroundColor = UIColor.clear optionTitle.numberOfLines = 0 return optionTitle }() var subtitle: UILabel = { let optionTitle = UILabel() optionTitle.font = UIFont(name: "Helvetica-bold", size: 14) optionTitle.textAlignment = .justified optionTitle.text = "label example" optionTitle.adjustsFontSizeToFitWidth = true optionTitle.textColor = blueMifel optionTitle.translatesAutoresizingMaskIntoConstraints = false optionTitle.backgroundColor = UIColor.clear optionTitle.numberOfLines = 0 return optionTitle }() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) addSubview(title) addSubview(subtitle) setAutoLayout() self.backgroundColor = UIColor.clear } required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } private func setAutoLayout() { NSLayoutConstraint.activate([ title.centerXAnchor.constraint(equalTo: self.leadingAnchor, constant: 8), title.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.30), title.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 0.90), title.centerYAnchor.constraint(equalTo: self.centerYAnchor), subtitle.centerXAnchor.constraint(equalTo: self.trailingAnchor, constant: -8), subtitle.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.60), subtitle.heightAnchor.constraint(equalTo: self.heightAnchor, multiplier: 0.90), subtitle.centerYAnchor.constraint(equalTo: self.centerYAnchor) ]) } }this class should display 2 messages one in the leading and one in the trailing anchor, that's why the difference betweenthis should be the main title for the celltableViewData = [CellData(opened: false, title: "1", sectionData: ["1.1", "1.2","1.3","1.4"]), CellData(opened: false, title: "2", sectionData: ["2.1", "2.2", "2.3"]) ]and then if user clicks whatever title should display this array, and show title and subtitle in the open celltableViewDataInside = [DataInside(opened: false, title: "1.1.1", sectionData: ["1.1.1"])]title should be an array thats for fact, if i want to display multiple information in multiple sub-cells witih sub-titlestableViewDataInside = [DataInside(opened: false, title: ["1.1.1", "2.2.2", "3.3.3"], sectionData: ["1.1.1", "2.2.2", "3.3.3"])]like this---------------------------------TITLE MAIN 1.1 (user clicks here)---------------------------------expandible table opens and shows --------------------------- TITLE SUBTITLE ---------------------------and the whole representation of what im trying to do is-------------------------------MAIN TITLE 1 of CellData(user clicks here), expandible table opens and shows ⬇--------------------------------- --------------------------------- 1.1 sectionData of CellData (user clicks here), expandible table opens and shows ⬇ -------------------------------- ------------------------------ TITLE SUBTITLE (of DataInside where TITLE is: title and SUBTITLE is: sectionData) ---------------------------
Mar ’20
Reply to UIColor Issues in Navigation Bar Settings? Xcode 12.1
Hi 🤙🏻 You miss the /255 should be like this: UIColor(red: 250/255, green: 190/255, blue: 110/255, alpha: 1) also try to set the color when you push the view let view = PasajerosPaso2View()         view.backgroundColor = UIColor.lightGray         navigationController.navigationBar.backgroundColor =  UIColor(red: 250/255, green: 190/255, blue: 110/255, alpha: 1)         let vc = factory.makePasajerosPaso2VC(view, coordinator: self)         navigationController.pushViewController(vc, animated: false)
Dec ’20
Reply to UICollectionView Inside of UItableViewCell no horizontal scrolling
Hi, the exact behaviour is do you see the full content wrapping around on next lines ? Or part of the collection remains hidden on the right ? the information charge fine in each UItableViewCell and part of the collection remains hidden on the right because is not scrollable. What happens when you click and drag in order to scroll ? Any change on the table cell ? while scrolling the UITableViewCells works fine you can scroll down and up, and cells information charge , but the UICollectionViews inside each UITableViewCells are not scrollable horizontally, and the information charge fine and about the link that was literally the first solution i tried
Mar ’21
Reply to UIcollectionView with array no loading sections
as you can see the items are not the same [MovieDataBase.episodess(episode_number: Optional(1), name: Optional("121045"), still_path: Optional("/b9hFk5kwRcFUorxLQsOHasJnbDH.jpg")), MovieDataBase.episodess(episode_number: Optional(2), name: Optional("131045"), still_path: Optional("/mSZDdQLHnDousFg35ndlmv42908.jpg")), MovieDataBase.episodess(episode_number: Optional(3), name: Optional("181045"), still_path: Optional("/57bidANnv5zdPmJckmPL9f4Ogb7.jpg")), MovieDataBase.episodess(episode_number: Optional(4), name: Optional("291045"), still_path: Optional("/swmIOzEJ8uIjCdd5B4w9Ln5qXsJ.jpg")), MovieDataBase.episodess(episode_number: Optional(5), name: Optional("301045"), still_path: Optional("/2x9v9YupwZnMBnvCUOwaOv8UEQV.jpg")), MovieDataBase.episodess(episode_number: Optional(6), name: Optional("311045"), still_path: Optional("/uFY25TSNrOxbL18jDV1pSjWPKEK.jpg")), MovieDataBase.episodess(episode_number: Optional(7), name: Optional("011145"), still_path: Optional("/8LGArTKq5oMnKR9AjdRd3ocxJWu.jpg")), MovieDataBase.episodess(episode_number: Optional(8), name: Optional("021145"), still_path: Optional("/yEBAannVEt2QhyUKyjlXhXrEVld.jpg")), MovieDataBase.episodess(episode_number: Optional(9), name: Optional("031145"), still_path: Optional("/nf1zvR7D4kN1Xa1wlxXeuUrWpOo.jpg")), MovieDataBase.episodess(episode_number: Optional(10), name: Optional("130146"), still_path: Optional("/1lTlSWY4chqpv1ibeQz4eYHaePf.jpg")), MovieDataBase.episodess(episode_number: Optional(11), name: Optional("140146"), still_path: Optional("/qTKxjZTbiCqZ6lywwfmfTLX8QnK.jpg")), MovieDataBase.episodess(episode_number: Optional(12), name: Optional("150146"), still_path: Optional("/8duv3ltJa7Olb721zsqcbss0kVx.jpg")), MovieDataBase.episodess(episode_number: Optional(1), name: Optional("Episode 1"), still_path: Optional("/24VlK7Ed5VFa0yE2kEmDPzyYks.jpg")), MovieDataBase.episodess(episode_number: Optional(2), name: Optional("Episode 2"), still_path: Optional("/eoyTsCYEAymTAhBgXIbIfW2jrwz.jpg")), MovieDataBase.episodess(episode_number: Optional(3), name: Optional("Episode 3"), still_path: Optional("/1EgiONNX9CgO6i4DjyeVBvsvT9v.jpg")), MovieDataBase.episodess(episode_number: Optional(4), name: Optional("Episode 4"), still_path: Optional("/4lZnqwPkNmnVEZ6ipID92BiWDkd.jpg")), MovieDataBase.episodess(episode_number: Optional(5), name: Optional("Episode 5"), still_path: Optional("/4wkH3s9d7YFvnjvQ24rS1pj4oUk.jpg")), MovieDataBase.episodess(episode_number: Optional(6), name: Optional("Episode 6"), still_path: Optional("/46XRAOhySNHl1O0qTHMUdUxfDcA.jpg")), MovieDataBase.episodess(episode_number: Optional(7), name: Optional("Episode 7"), still_path: Optional("/lbVYNXOtQSVU69ee7qbHWJ1f7b8.jpg")), MovieDataBase.episodess(episode_number: Optional(8), name: Optional("Episode 8"), still_path: Optional("/95UudD6foD0V7xJc345sJSZ9vUW.jpg")), MovieDataBase.episodess(episode_number: Optional(9), name: Optional("Episode 9"), still_path: Optional("")), MovieDataBase.episodess(episode_number: Optional(10), name: Optional("Episode 10"), still_path: Optional("")), MovieDataBase.episodess(episode_number: Optional(11), name: Optional("Episode 11"), still_path: Optional(""))]
Mar ’21
Reply to UIcollectionView with array no loading sections
Print statements inside CellForItemAt and UICollectionViewCell model Optional(4) 3 Optional(4) model Optional(5) 4 Optional(5) model Optional(6) 5 Optional(6) model Optional(7) 6 Optional(7) model Optional(8) 7 Optional(8) model Optional(9) 8 Optional(9) model Optional(10) 9 Optional(10) model Optional(11) 10 Optional(11) model Optional(12) 11 Optional(12) model Optional(1) 12 Optional(1) model Optional(2) 13 Optional(2) model Optional(3) 14 Optional(3) model Optional(4) 15 Optional(4) model Optional(5) 16 Optional(5) model Optional(6) 17 Optional(6) model Optional(7) 18 Optional(7) model Optional(8) 19 Optional(8) model Optional(9) 20 Optional(9) model Optional(10) 21 Optional(10) model Optional(11) 22 Optional(11)
Mar ’21
Reply to UIcollectionView with array no loading sections
Why do you need this if-statement? because i have 2 CollectionsView in the same View Are you still trying to show UICollectionView inside each UITableViewCell as shown in another thread of yours? It shows already and can be scrolled horizontally, i solve my problem now the thing is it shows the same cell 0 content in all cells Please show your latest definition of NumberOfSeasonsCell if you are still using it. here's the code i'm not using this any more because it detects how may arrows will be display for current show and can be scrolled class NumberOfSeasonsCell: UITableViewCell, ViewDelegate {     var compactConstraints: [NSLayoutConstraint] = [NSLayoutConstraint]()     var regularConstraints: [NSLayoutConstraint] = [NSLayoutConstraint]()     var largeConstraints: [NSLayoutConstraint] = [NSLayoutConstraint]()     lazy var seasonsCollectionView: UICollectionView = {         let layout = UICollectionViewFlowLayout()         layout.scrollDirection = .horizontal         layout.minimumLineSpacing = 30         let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)         cv.backgroundColor = UIColor.clear         cv.register(SeasonCell.self, forCellWithReuseIdentifier: "identifierSeasons")         cv.showsHorizontalScrollIndicator = false         cv.translatesAutoresizingMaskIntoConstraints = false         return cv     }()   override func awakeFromNib() {         super.awakeFromNib()         // Initialization code     }     override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {         super.init(style: style, reuseIdentifier: reuseIdentifier)         initComponents()     }     required init?(coder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }     func setCollectionViewDataSourceDelegateD: UICollectionViewDataSource & UICollectionViewDelegate(_ dataSourceDelegate: D, forRow row: Int) {         seasonsCollectionView.delegate = dataSourceDelegate         seasonsCollectionView.dataSource = dataSourceDelegate         seasonsCollectionView.tag = row         seasonsCollectionView.setContentOffset(seasonsCollectionView.contentOffset, animated:false) // Stops collection view if it was scrolling.         seasonsCollectionView.reloadData()     } var collectionViewOffset: CGFloat {         set { seasonsCollectionView.contentOffset.x = newValue }         get { return seasonsCollectionView.contentOffset.x }     }     func initComponents() {         addComponents()         setAutolayout()         activateCurrentLayout()     }     func addComponents() {         self.addSubview(seasonsCollectionView)     }     func setAutolayout() {         largeConstraints = [             seasonsCollectionView.centerYAnchor.constraint(equalTo: self.centerYAnchor),             seasonsCollectionView.centerXAnchor.constraint(equalTo: self.centerXAnchor),             seasonsCollectionView.widthAnchor.constraint(equalTo: self.widthAnchor),             seasonsCollectionView.heightAnchor.constraint(equalTo: self.heightAnchor),         ]     }   func activateCurrentLayout() {         NSLayoutConstraint.activate(largeConstraints)     } } extension UITableViewCell {     open override func addSubview(_ view: UIView) {         super.addSubview(view)         sendSubviewToBack(contentView)     } } Also all the code related to UI.castCollectionView is needed. UI.castCollectionView is not part of the problem because its an independent UICollectionView working fine the problem is with cell and cell model of the other UICollectionView inside the else cellForItemAt let arreglo = arraySeasonsEpisodes[indexPath.item]             cell.model = arreglo lazy var castCollectionView: UICollectionView = {         let layout = UICollectionViewFlowLayout()         layout.scrollDirection = .horizontal         layout.minimumLineSpacing = 20         let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)         cv.backgroundColor = UIColor.clear         cv.register(CastCell.self, forCellWithReuseIdentifier: "identifierCast")         cv.isPagingEnabled = true      cv.showsVerticalScrollIndicator = false      cv.showsHorizontalScrollIndicator = false      cv.translatesAutoresizingMaskIntoConstraints = false         return cv     }() extension SelectedShowVC: UICollectionViewDelegate, UICollectionViewDataSource, UICollectionViewDelegateFlowLayout {     func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) - Int {         if collectionView == UI.castCollectionView{             return arrayCast.count         }else{             return arraySeasonsEpisodes.count             //return model[collectionView.tag].count         }              }          func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) - UICollectionViewCell {                  if collectionView == UI.castCollectionView{             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifierCast", for: indexPath) as! CastCell                                   cell.backgroundColor = .clear             cell.model = arrayCast[indexPath.item]                          return cell         }else{                                           let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifierSeasons", for: indexPath) as! SeasonCell             cell.backgroundColor = .clear             let arreglo = arraySeasonsEpisodes[indexPath.item]             cell.model = arreglo                                       print(indexPath.item, arreglo.episode_number)                         return cell         }               }
Mar ’21
Reply to UIcollectionView with array no loading sections
I'm sorry i didn't copy the entire print model Optional(1) 0 Optional(1) model Optional(2) 1 Optional(2) model Optional(3) 2 Optional(3) model Optional(4) 3 Optional(4) model Optional(5) 4 Optional(5) model Optional(6) 5 Optional(6) model Optional(7) 6 Optional(7) model Optional(8) 7 Optional(8) model Optional(9) 8 Optional(9) model Optional(10) 9 Optional(10) model Optional(11) 10 Optional(11) model Optional(12) 11 Optional(12) model Optional(1) 12 Optional(1) model Optional(2) 13 Optional(2) model Optional(3) 14 Optional(3) model Optional(4) 15 Optional(4) model Optional(5) 16 Optional(5) model Optional(6) 17 Optional(6) model Optional(7) 18 Optional(7) model Optional(8) 19 Optional(8) model Optional(9) 20 Optional(9) model Optional(10) 21 Optional(10) model Optional(11) 22 Optional(11) model Optional(9) 20 Optional(9) this is how i storage the information from the JSON response let toneCategories = jsonDictionary["episodes"] as? [NSDictionary] ?? []                        for category in toneCategories {                         let show = episodess(dictionary: category)                         arraySeasonsEpisodes.append(show)                         let number = Int(season_number) ?? 0                         let reversedCollection = (1 ... number)                         for (index, element) in reversedCollection.enumerated() {                             let fixed = index - 1                             if fixed = 0 {                                 let arreglo = arregloBidimencional(arreglo: [show], tag: 0)                                 arregloDeArreglos.append([arreglo])                             }else if fixed = 1{                                 let fixed2 = index                                 let arreglo = arregloBidimencional(arreglo: [show], tag: fixed2)                                 arregloDeArreglos.append([arreglo])                             }                         }                        } the struct for arregloBidimencional var arregloDeArreglos: [[arregloBidimencional]] = [] struct arregloBidimencional: Initiable {     let episodes: [episodess]?     let tack: Int?          init() {                  self.episodes = [episodess]()         self.tack = 0                  }          init(arreglo: [episodess], tag: Int) {         self.episodes = arreglo         self.tack = tag     } }
Mar ’21
Reply to UIcollectionView with array no loading sections
this is the entire code of the cell import UIKit class SeasonCell: UICollectionViewCell {          var model: episodess? {         didSet {             guard let viewModel = model else { return }             let episodio = viewModel.episode_number             let nombre = viewModel.name             let guardado = viewModel.still_path             episodeNumber.text = "Episode Number: \(episodio ?? 0)"             episodeName.text = "Episode Name: \(nombre ?? "")"             let image = "w500\(guardado ?? "")"             if image == "" || image == "undefined" {                 seasonImage.image = UIImage()                 seasonImage.contentMode = .scaleAspectFill             }else{                 seasonImage.downloaded(from: image)                 seasonImage.contentMode = .scaleAspectFill             }             print("model", viewModel.episode_number) //         }     }     override func prepareForReuse() {         super.prepareForReuse()              }          override init(frame: CGRect) {         super.init(frame: frame)                  setupViews()     }          let seasonImage: UIImageView = {         let iv = UIImageView()         iv.contentMode = .scaleToFill         iv.backgroundColor = .clear         iv.image = UIImage(named: "")         iv.translatesAutoresizingMaskIntoConstraints = false         return iv     }()          var episodeNumber: UILabel = {         let label = UILabel()         label.text = ""         label.numberOfLines = 1         label.textAlignment = .left         label.font = Fonts.AVENIR.of(size: 10)         label.translatesAutoresizingMaskIntoConstraints = false         label.textColor = UIColor.white         return label              }()          var episodeName: UILabel = {         let label = UILabel()         label.text = ""         label.numberOfLines = 1         label.textAlignment = .left         label.font = Fonts.AVENIR.of(size: 10)         label.translatesAutoresizingMaskIntoConstraints = false         label.textColor = UIColor.white         return label              }()          func setupViews() {         addSubview(seasonImage)         addSubview(episodeNumber)         addSubview(episodeName)                           NSLayoutConstraint.activate([             seasonImage.centerYAnchor.constraint(equalTo: self.centerYAnchor),             seasonImage.centerXAnchor.constraint(equalTo: self.centerXAnchor),             seasonImage.widthAnchor.constraint(equalTo: self.widthAnchor, multiplier: 1),             seasonImage.heightAnchor.constraint(equalTo: self.widthAnchor, multiplier: 0.6),                                       episodeNumber.leftAnchor.constraint(equalTo: seasonImage.leftAnchor),             episodeNumber.topAnchor.constraint(equalTo: seasonImage.bottomAnchor, constant: 8),             episodeNumber.rightAnchor.constraint(equalTo: seasonImage.rightAnchor),             episodeName.leftAnchor.constraint(equalTo: episodeNumber.leftAnchor),             episodeName.rightAnchor.constraint(equalTo: seasonImage.rightAnchor),             episodeName.topAnchor.constraint(equalTo: episodeNumber.bottomAnchor, constant: 8),                ])              }          required init?(coder aDecoder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }      }
Mar ’21
Reply to UIcollectionView with array no loading sections
i tried like this but same problem             let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "identifierSeasons", for: indexPath) as! SeasonCell             cell.backgroundColor = .clear             let arreglo = arraySeasonsEpisodes[indexPath.item]             cell.model = arreglo             cell.setupViews()                          print(indexPath.item, arreglo.episode_number)                         return cell
Mar ’21
Reply to Set an array of arrays inside of UICollectionView that's inside a UITableView and return the correct number of items?
Here's the data as JSON ArrayJson - https://developer.apple.com/forums/content/attachment/d8cce88e-66d4-423d-9f1d-58001fa799f4 here's the whole VC ViewController - https://developer.apple.com/forums/content/attachment/6791613a-fb72-4d34-adfd-9f1a6f2c6138 Especially, we need to know how arregloDeArreglos, modelOfSeason or any other data used for dataSource. var modelOfSeason = arraySeasonsEpisodes its only used as a global variable and arregloDeArreglos it's only used in cellForRowAt
Mar ’21
Reply to Set an array of arrays inside of UICollectionView that's inside a UITableView and return the correct number of items?
😅 sorry i have not experienced with this. i don't have the knowledge to manage information from a UItable to UIcolectionview so the only way i could solve it is making a global variable to move the previous information and loaded to the UIcollectionview now i'm trying to investigate how can i send information from the table to collection i'm trying to make it the same way i treated the information in the UICollectionViewCell using didSet but still not clue here's the code so far import UIKit var modelOfSeason = arraySeasonsEpisodes //this is the global class NumberOfSeasonsCell: UITableViewCell, ViewDelegate {     var modelo: arregloBidimencional? {         didSet {             guard let viewModel = modelo else { return }             let array = viewModel.arregloDeEpisodios                                   }     }          var compactConstraints: [NSLayoutConstraint] = [NSLayoutConstraint]()     var regularConstraints: [NSLayoutConstraint] = [NSLayoutConstraint]()     var largeConstraints: [NSLayoutConstraint] = [NSLayoutConstraint]()               lazy var seasonsCollectionView: UICollectionView = {         let layout = UICollectionViewFlowLayout()         layout.scrollDirection = .horizontal         layout.minimumLineSpacing = 30         let cv = UICollectionView(frame: .zero, collectionViewLayout: layout)         cv.backgroundColor = UIColor.clear         cv.register(SeasonCell.self, forCellWithReuseIdentifier: "identifierSeasons")         cv.showsHorizontalScrollIndicator = false         cv.translatesAutoresizingMaskIntoConstraints = false         return cv     }()     override func awakeFromNib() {         super.awakeFromNib()         // Initialization code     }     func contenido(array: arregloBidimencional){              }          override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {         super.init(style: style, reuseIdentifier: reuseIdentifier)                  initComponents()     }          required init?(coder: NSCoder) {         fatalError("init(coder:) has not been implemented")     }          func setCollectionViewDataSourceDelegateD: UICollectionViewDataSource & UICollectionViewDelegate(_ dataSourceDelegate: D, forRow row: Int) {         seasonsCollectionView.delegate = dataSourceDelegate         seasonsCollectionView.dataSource = dataSourceDelegate         seasonsCollectionView.tag = row         seasonsCollectionView.setContentOffset(seasonsCollectionView.contentOffset, animated:false) // Stops collection view if it was scrolling.         seasonsCollectionView.reloadData()     }               var collectionViewOffset: CGFloat {         set { seasonsCollectionView.contentOffset.x = newValue }         get { return seasonsCollectionView.contentOffset.x }     }               func initComponents() {         addComponents()         setAutolayout()         activateCurrentLayout()              }          func addComponents() {         self.addSubview(seasonsCollectionView)              }          func setAutolayout() {         largeConstraints = [             seasonsCollectionView.centerYAnchor.constraint(equalTo: self.centerYAnchor),             seasonsCollectionView.centerXAnchor.constraint(equalTo: self.centerXAnchor),             seasonsCollectionView.widthAnchor.constraint(equalTo: self.widthAnchor),             seasonsCollectionView.heightAnchor.constraint(equalTo: self.heightAnchor),         ]     }          func activateCurrentLayout() {         NSLayoutConstraint.activate(largeConstraints)     } } extension UITableViewCell {     open override func addSubview(_ view: UIView) {         super.addSubview(view)         sendSubviewToBack(contentView)     } }
Mar ’21