uitableview

How to get the selected cell index path Swift [duplicate]

左心房为你撑大大i 提交于 2020-07-23 08:22:36
问题 This question already has answers here : swift: how to get the indexpath.row when a button in a cell is tapped? (18 answers) Closed 2 years ago . I have a table view in my VC. Inside the cell there are some lables and buttons. I passed the values in my labels, now i'm trying that when i hit a button that is also in that cell it should increment the value of the label. The value in that label is coming from previous VC. I have made a delegate for it when button is pressed, when button is

How to get the selected cell index path Swift [duplicate]

試著忘記壹切 提交于 2020-07-23 08:21:28
问题 This question already has answers here : swift: how to get the indexpath.row when a button in a cell is tapped? (18 answers) Closed 2 years ago . I have a table view in my VC. Inside the cell there are some lables and buttons. I passed the values in my labels, now i'm trying that when i hit a button that is also in that cell it should increment the value of the label. The value in that label is coming from previous VC. I have made a delegate for it when button is pressed, when button is

How to get the selected cell index path Swift [duplicate]

。_饼干妹妹 提交于 2020-07-23 08:19:19
问题 This question already has answers here : swift: how to get the indexpath.row when a button in a cell is tapped? (18 answers) Closed 2 years ago . I have a table view in my VC. Inside the cell there are some lables and buttons. I passed the values in my labels, now i'm trying that when i hit a button that is also in that cell it should increment the value of the label. The value in that label is coming from previous VC. I have made a delegate for it when button is pressed, when button is

Swift - Movable rows in tableView only within a section, not between

余生长醉 提交于 2020-07-22 00:41:21
问题 Is there a way to prevent cells in a tableView from being moved to a different section? The sections have data for different types of cells, so the app crashes when the user tries to drag a cell into a different section. I would like to only allow the user to move a cell inside the section, and not in between sections. Relevant code is below: override func tableView(_ tableView: UITableView, canMoveRowAt indexPath: IndexPath) -> Bool { return true } override func tableView(_ tableView:

Querying Realm to populate numberOfRowsInSection and cellForRowAt with Multiple Sections using Realm and Swift

旧街凉风 提交于 2020-07-21 08:09:05
问题 I'm new to Realm and Swift, and to this site for that matter, so please forgive me if my question is poorly worded, but I will do my best. Here goes... Basically I'm trying to build a Gym App. The idea is to allow the user to type out the title of their workout and to select a day of the week from a Picker View, to assign to that particular workout. With that said, I'm having some trouble figuring out how to code the numberOfRowsInSection function so that it returns the number of rows based

Querying Realm to populate numberOfRowsInSection and cellForRowAt with Multiple Sections using Realm and Swift

喜你入骨 提交于 2020-07-21 08:08:41
问题 I'm new to Realm and Swift, and to this site for that matter, so please forgive me if my question is poorly worded, but I will do my best. Here goes... Basically I'm trying to build a Gym App. The idea is to allow the user to type out the title of their workout and to select a day of the week from a Picker View, to assign to that particular workout. With that said, I'm having some trouble figuring out how to code the numberOfRowsInSection function so that it returns the number of rows based

Duplication in values of tableView when Scrolling Swift

北城余情 提交于 2020-07-15 08:14:34
问题 I have a tableView to display timings of week days timingsArray is used in tableView to display timings timingsArray of type timingObj class timingObj { var dayNo: Int? var open: String? var close: String? var dayName: String? init(json: JSON){ // to take data from json } init(name: String, number: Int){ self.dayName = name self.dayNo = number } } in tableView i want to display all days and their timings, if the day does not have timing then timing cell will be empty let cell = tableView

How can I reload items without removing and inserting with UITableViewDiffableDataSource?

若如初见. 提交于 2020-07-09 03:54:32
问题 I'm implementing a search screen in my app using UITableViewDiffableDataSource . Each cell represents a search hit and highlights the search match in the cell title, kind of like Xcode's Open Quickly window highlights portions of its result items. As text is typed into the search field, I update the results list. Results move up and down in the list as their relevance changes. The trick is that I need to force every cell to re-render every time the search text changes, because a new search

How can I reload items without removing and inserting with UITableViewDiffableDataSource?

╄→гoц情女王★ 提交于 2020-07-09 03:52:29
问题 I'm implementing a search screen in my app using UITableViewDiffableDataSource . Each cell represents a search hit and highlights the search match in the cell title, kind of like Xcode's Open Quickly window highlights portions of its result items. As text is typed into the search field, I update the results list. Results move up and down in the list as their relevance changes. The trick is that I need to force every cell to re-render every time the search text changes, because a new search

Detect when UITableViewCell did load

久未见 提交于 2020-07-06 08:44:12
问题 I need to be able to detect when my custom UITableViewCell has been loaded on screen, so that I can programmatically do stuff to the view inside it. The only code I could get working was implementing layoutSubviews() inside the custom UITableViewCell , but this is bad practice because layoutSubviews() is called more than one time. Also, putting my code in awakeFromNib() doesn't work because I need to call a delegate property, which hasn't been set at that point. How can I achieve this? 回答1: