uitableview

Crash with tableView.deleteRows(at:, with:)

不羁岁月 提交于 2021-02-07 07:14:37
问题 I have an erratic problem with an app I'm developing. I have an array of tracks that is displayed in a table view. In this table view a user can swipe a single track left and a menu with three items appears. One of which is a delete action. It is with this action I have a problem. The menu is implemented in the UITableViewDelegate method: override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? I retrieve the selected row with the

Crash with tableView.deleteRows(at:, with:)

半腔热情 提交于 2021-02-07 07:13:27
问题 I have an erratic problem with an app I'm developing. I have an array of tracks that is displayed in a table view. In this table view a user can swipe a single track left and a menu with three items appears. One of which is a delete action. It is with this action I have a problem. The menu is implemented in the UITableViewDelegate method: override func tableView(_ tableView: UITableView, editActionsForRowAt indexPath: IndexPath) -> [UITableViewRowAction]? I retrieve the selected row with the

Correct implementation of cellForRowAtIndexPath in Swift 2.0

≯℡__Kan透↙ 提交于 2021-02-07 06:24:28
问题 Is the following implementation of cellForRowAtIndexPath the technically correct best-practice way taking into account the unwrapping of optionals class MyTableViewController: UITableViewController { var cell : UITableViewCell? // other methods here override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { cell = tableView.dequeueReusableCellWithIdentifier("ItemCell")! as UITableViewCell let myItem = items[indexPath.row] cell!.textLabel

Expand only the cell that has been tapped

*爱你&永不变心* 提交于 2021-02-07 04:28:20
问题 I have some code in my app that expands a cell when it is tapped. The problem is that I haven't figured out how to only expand the cell that has been tapped. At the moment my code just expands all of the cells. Here is my code: override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { selectedRowIndex = indexPath tableView.beginUpdates() tableView.endUpdates() } override func tableView(tableView: UITableView, heightForRowAtIndexPath indexPath:

Animating CALayer shadow simultaneously as UITableviewCell height animates

Deadly 提交于 2021-02-07 03:52:22
问题 I have a UITableView that I am attempting to expand and collapse using its beginUpdates and endUpdates methods and have a drop shadow displayed as that's happening. In my custom UITableViewCell, I have a layer which I create a shadow for in layoutSubviews : self.shadowLayer.shadowColor = self.shadowColor.CGColor; self.shadowLayer.shadowOffset = CGSizeMake(self.shadowOffsetWidth, self.shadowOffsetHeight); self.shadowLayer.shadowOpacity = self.shadowOpacity; self.shadowLayer.masksToBounds = NO;

Animating CALayer shadow simultaneously as UITableviewCell height animates

前提是你 提交于 2021-02-07 03:48:13
问题 I have a UITableView that I am attempting to expand and collapse using its beginUpdates and endUpdates methods and have a drop shadow displayed as that's happening. In my custom UITableViewCell, I have a layer which I create a shadow for in layoutSubviews : self.shadowLayer.shadowColor = self.shadowColor.CGColor; self.shadowLayer.shadowOffset = CGSizeMake(self.shadowOffsetWidth, self.shadowOffsetHeight); self.shadowLayer.shadowOpacity = self.shadowOpacity; self.shadowLayer.masksToBounds = NO;

UITableViewController vs UIViewController

送分小仙女□ 提交于 2021-02-05 21:51:43
问题 What all does UITableViewController get me that makes it actually useful? Is there any bonus is using it instead of just using a UIViewController for views with UITableViews in them? I ask because I want my views with UITableViews to inherit from a base view controller (which inherits from UIViewController ). If I use a UITableViewController then having a base class for all my views becomes more difficult. 回答1: Not much. It provides some conveniences, but you never really need it; I often don

UITableViewController vs UIViewController

只谈情不闲聊 提交于 2021-02-05 21:40:02
问题 What all does UITableViewController get me that makes it actually useful? Is there any bonus is using it instead of just using a UIViewController for views with UITableViews in them? I ask because I want my views with UITableViews to inherit from a base view controller (which inherits from UIViewController ). If I use a UITableViewController then having a base class for all my views becomes more difficult. 回答1: Not much. It provides some conveniences, but you never really need it; I often don

SwiftUI List with Section Index on right hand side?

最后都变了- 提交于 2021-02-05 20:33:34
问题 Is it possible to have a List with an index on the right hand side, like the example below in SwiftUI? 回答1: I was looking for a solution to the same question , but it currently the only option that we might have right now is using UITableView as View. import SwiftUI import UIKit struct TableView: UIViewRepresentable { func makeUIView(context: Context) -> UITableView { let tableView = UITableView(frame: .zero, style: .plain) tableView.delegate = context.coordinator tableView.dataSource =

UITableViewCell Height Issue

假如想象 提交于 2021-02-05 12:21:02
问题 I'm actually trying to make the image view height dynamic I have tried UITableViewAutomaticDimension in the cell class I have set the image's dynamic height based on the aspect constraint 回答1: Well, you can't achieve the dynamic height of cell with UITableViewAutomaticDimension on the basis of image's constraints. BUT image's height and width can help you in this. There is a plenty of help regarding this issue is available in following answer: Dynamic UIImageView Size Within UITableView 回答2: