uitableview

I am reloading my tableView after fetching data from API and after reloading tableView simply does not render any cell as I see in view debugger

我与影子孤独终老i 提交于 2021-02-05 12:03:41
问题 This is my API Fetch method where I am reloading my tableview.After reloading tableview does not render any cell. ``` API.shared.fetchAccomodations(completion: { (accResponse, error) in if let err = error { print("Failed to fetch accomodation Information ::" , err.localizedDescription) } if let response = accResponse { self.accomodationsData = response DispatchQueue.main.async { self.accomodationsData = response print(self.accomodationsData.count , self.accomodationsData) self.tableView

Change in firebase doesn't refresh table - Tables not displaying user nodes from arrays

℡╲_俬逩灬. 提交于 2021-02-05 11:55:54
问题 I am trying to have two arrays, used as dataSources for two tableViews. One array contains user type: macro and the other array contains user type: micro. If a user type is changed from macro to micro (and vice-versa) I want to remove the user from one table and add it to the other. Currently I am able to update the user's tag if changed in Firebase Database and have it appear in the proper array when the app is restarted. The observe function only collects it once and if it is changed, it

How to manage multiple timers in one viewController?

北慕城南 提交于 2021-02-05 11:35:23
问题 I'm working on Timers app and cannot understand how I can make work multiple timers for each cell. I start and pause timers at didSelectRowAt: override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { tableView.deselectRow(at: indexPath, animated: true) let cell = tableView.cellForRow(at: indexPath) as! TimerTableViewCell let item = timers.items[indexPath.row] item.toggle() print(item) startPauseTimer(for: cell, with: item) } And this is my code for

Is weak self needed for table view cell button closure

时光怂恿深爱的人放手 提交于 2021-02-05 08:56:31
问题 In trying to avoid retain cycles, would using [weak self] in in a UITableViewCell button action be necessary? Example: in ViewController's cellForRow cell.buttonAction = { (cell) [weak self] in self.someFunction() } in TableViewCell class var buttonAction: ((UITableViewCell) -> Void)? @IBAction func buttonPressed(_ sender: Any) { buttonAction?(self) } 回答1: The key line to think about is: var buttonAction: ((UITableViewCell) -> Void)? You are offering to store a function long-term in an

Swift TableView segue to new ViewController with wrong index path (penultimate selection)

江枫思渺然 提交于 2021-02-05 08:28:07
问题 I have a weird problem. I have two TableViews one for showing Projects and one for showing all Team Members. With both TableViews I have the same bug. When a user clicks on a Project/ Team Member I want to show the Details for it. The weird thing is, when running the app and I select a Project/ Team Member for the first time, nothing is happening. When I then select another one, it shows me the details of the previous selected one. I hope someone can help me with that. Also a weird thing is,

I don't understand a completion handler and I need one in my code

让人想犯罪 __ 提交于 2021-01-29 17:44:08
问题 I capture the data from Firestore and assign to array, someone in other question told me maybe I need a completion handler but I don't understand how to work, it would be very helpful if you help me with the code and explain this concept to me. class PetsTVC: UITableViewController { var db: Firestore! let uid = Auth.auth().currentUser?.uid var petslist = [String]() var pid = "" var pets = [paw]() override func viewDidLoad() { super.viewDidLoad() self.loadPets() DispatchQueue.main.async { self

How to make Xib footer items Clickable in tableView Swift

与世无争的帅哥 提交于 2021-01-29 16:42:11
问题 I am struggling to make my footer items clickable in tableView. In tableView I am using two different Xib's and I have used tableView - didSelect function as a expandable cell on click. 1) Main Xib 2) Child_View - Footer Xib Now on footer items which is childView - I also want to make clickable action so on clicking it will navigate to viewController with their detail information. How can I achieve this because didSelect is already in use for expandable cells? Attaching three images Main Xib

UITableViewCell with intrinsic height based on width

被刻印的时光 ゝ 提交于 2021-01-29 15:39:44
问题 So I have made custom view ExpressionView for visualizing mathematical expression. Every part of expression is UILabel holding one number or operation, and labels are aligned inside the ExpressionView in right-justified rows. I expect ExpressionView to have width defined by autolayout constraints from outside, but height should be intrinsic, depending on how many rows of labels I will have to make for a given width. The aligning methods works well, I use frame.size of each label and width of

iOS: I am trying to send the selected rows(data) to another controller.

时光总嘲笑我的痴心妄想 提交于 2021-01-29 14:26:12
问题 I have a tableview for which I am using - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath { [tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryCheckmark; } I have an NSArray *selectedDiscounts which I have assigned like this selectedDiscounts = [self.tableView indexPathsForSelectedRows]; I have to pass the selected table rows data to another controller where I will be populating the tableView with selected rows. The

how to get table view row and push to viewController from collectionView that's inside a tableViewCell when tapped button inside collectionView cell

旧街凉风 提交于 2021-01-29 14:13:06
问题 My hierarchy like this UINavigationController->UITableviewController -> UITableViewCell -> UICollectionView-> UICollectionViewCell I have a button inside collectionView cell and I set like this: class AccountTypeCollectionViewCell: UICollectionViewCell { @IBOutlet weak var AccountTypeView: UIView! @IBOutlet weak var imgAccountType: UIImageView! @IBOutlet weak var lblAccountTypeTitle: UILabel! @IBOutlet weak var txtAccountTypeDescription: UITextView! @IBOutlet weak var btnMoreInfo: UIButton!