Post

Replies

Boosts

Views

Activity

Reply to TableView relsoaddata from textField on the same viewController with TableView
I would thus investigate the sequence of events (by just adding some prints to start with. Possibly, when loadData() is called, data are not yet loaded… override func viewDidAppear(_ animated: Bool) { super.viewDidAppear(true) print(#function, "going to loadData") // ==== loadData() } func loadData() { r_feedback(rtaskId: idTask.text ?? "") print(#function, "going to buttonChange") // ==== buttonChange() } func r_feedback(rtaskId: String) { var singleFeed = myFeedback() self.arrayOfFeedback.removeAll() queryFeedback(taskId: rtaskId).findObjectsInBackground { (objects, error) in if let objects = objects { if (objects.count 0) { print(#function, "queryFeedback") // ==== for eachFeed in objects { singleFeed.feedDate = eachFeed.createdAt! singleFeed.userNameFrom = eachFeed["UserNameFrom"] as? String singleFeed.feedMessage = eachFeed["TaskFeedback"] as? String singleFeed.atype = eachFeed["AType"] as? Int self.arrayOfFeedback.append(singleFeed) } } else { singleFeed.feedDate = nil singleFeed.userNameFrom = "" singleFeed.feedMessage = "" singleFeed.atype = nil } DispatchQueue.main.async { print(#function, "going to reloadData") // ==== self.fTableView.reloadData() } } } } func buttonChange() { let stat = taskStatus?.text let rqType = Int(reqTypeIndex.text ?? "") ?? 0 switch(rqType) { case 0: if (stat == status[1]) || (stat == status[3]) { statusChange(imageLabel: task_image[2]) } else { statusChange(imageLabel: "") } case 1: if (stat == status[2]) { statusChange(imageLabel: task_image[3]) } else { statusChange(imageLabel: "") } default: statusChange(imageLabel: "") } print(#function, "button has changed") // ==== } Please show the complete log.
Topic: App & System Services SubTopic: Core OS Tags:
Mar ’21
Reply to UIcollectionView with array no loading sections
So, next test I would do is the didSet, to check: if it is properly called if the content of model is correct Could you add 2 print statements: func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) - UICollectionViewCell { if collectionView == UI.castCollectionView{ 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 } and 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 = "https :// image.tmdb.org/t/p/w500\(guardado ?? "")" if image == "" || image == "undefined" { seasonImage.image = UIImage(named: "") seasonImage.contentMode = .scaleAspectFill } else { seasonImage.downloaded(from: image) seasonImage.contentMode = .scaleAspectFill } print("model", model.episode_number) // } } Note: struct names should start with Uppercase. What is Initiable ?
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to How fix tableView scroll problem when keyboard is open?
OK, so you need to reload the table. But this code cell.priceText.delegate = self cell.priceText.addTarget(self, action: #selector(textChanged(_:)), for: .editingChanged) cell.priceText.addTarget(self, action: #selector(onTextFieldTap), for: .touchDown) should be in cellForRow. Could you also try: to comment out reloadData() to see if the problem disappear. And also try to add a reselect after reloadData() tableView.reloadData() tableView.electRow(at: index, animated: true, scrollPosition: UITableViewScrollPosition.none) // May test other UITableViewScrollPosition
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Legacy Segmented Control style?
If that's not enough, you could define your complete custom segmentedControl. But note that unless you have a compelling reason to do so, it's not a great idea to go against standard control design. Very rapidly, your app will look outdated and surprise the users.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Limiting the number of questions for an indexpath
about 100 questions in an index path What do you mean, in a tabView ? want the game to end at say 30 questions, So, just create a property in the class var questionsAsked = 0 Each time you ask a question, increment it by 1 questionsAsked += 1 And before asking a new question, test if questionsAsked = 30 { // alert user that game is over } If that answers your question, don't forget to close the thread by marking the correct answer, otherwise, please explain more your problem.
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to UI Elements in TableViewCell are not working by touching, why?
This is not the code, it is something you have edited (line 109, 123, …) So please copy the exact code. And use Paste and match style to avoid all the extra lines, like this: class SearchCell: UITableViewCell, UISearchBarDelegate { let searchbar = UISearchBar() override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) { super.init(style: style, reuseIdentifier: reuseIdentifier) addSubview(searchbar) } required init?(coder: NSCoder) { fatalError("init(coder:) has not been implemented") } func setConstraints() { searchbar.placeholder = "Country, City" searchbar.searchBarStyle = .minimal let TapGesture = UITapGestureRecognizer(target: self, action: #selector(searchBarTapped)) searchbar.addGestureRecognizer(TapGesture) searchbar.isUserInteractionEnabled = true // Constraints searchbar.translatesAutoresizingMaskIntoConstraints = false searchbar.centerYAnchor.constraint(equalTo: centerYAnchor).isActive = true searchbar.leadingAnchor.constraint(equalTo: leadingAnchor, constant: 10).isActive = true searchbar.widthAnchor.constraint(equalToConstant: 380).isActive = true searchbar.heightAnchor.constraint(equalToConstant: 40).isActive = true } @objc func searchBarTapped() { searchbar.delegate = self } override func awakeFromNib() { super.awakeFromNib() { } override func setSelected(_ selected: Bool, animated: Bool) { super.setSelected(selected, animated: animated) } } Why do you set the delegate in searchBarTapped() ? That's too late. You should have done it earlier, probably in awake or in init.
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21
Reply to Legacy Segmented Control style?
What don't you like ? Rounded corners ? If so, could you try to subclass UISegmentedControl as follows: class SquareSegmentedControl: UISegmentedControl { override func layoutSubviews() { super.layoutSubviews() layer.cornerRadius = 0 for view in self.subviews { view.roundCorners(corners: UIRectCorner.allCorners, radius: 0) } } } If there are other points which cause problem, have a look here. https ://medium. com/flawless-app-stories/ios-13-uisegmentedcontrol-3-important-changes-d3a94fdd6763
Topic: Programming Languages SubTopic: Swift Tags:
Mar ’21
Reply to Multiple Table Views
Where is the other tableView ? In another ViewController ? I assume it is in another VC. have you checked that names is not empty ? You can test in viewDidLoad by adding print("number of names", names.count) Have you defined dataSource and delegate for the tableView ? You should do it directly in IB (as tableView is declared as IBOutlet) or in code. In this case, add in viewDidLoad: tableView.delegate = self tableView.dataSource = self Notes: you should give a more significant name to tableView. Such as namesTableView. To do so, right click on tableView in     @IBOutlet weak var tableView: UITableView! and select RefactorRename enter the new name (it will change everywhere, including in IB which is essential) code is hard to read lines 52/53 or 32 or 64. tableView.deselectRow(at: indexPath, animated: true)} func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) - Int { return names.count } You should mark more clearly the separation between func with an extra line: // tableView.deselectRow(at: indexPath, animated: true) } func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) - Int { return names.count }
Mar ’21
Reply to set UILabel's backgroundColor to nil is incorrect
 set the tt.backgroundColor is nil This should results in a transparent background color. Why nil and not .clear ? I adjust tt.text=@"abcd中" I tried (in Swift, no change). Still black if color is nil. Where do you change the value ? In viewDidLoad ? Reason may be that chinese characters are handled specially when drawing ? See this: https://stackoverflow.com/questions/48056901/setting-nil-background-for-uilabel-for-iphone-application
Topic: UI Frameworks SubTopic: UIKit Tags:
Mar ’21