uitableview

UITableViewCell as UIView from XIB

霸气de小男生 提交于 2020-08-25 05:17:53
问题 I have CustomTableViewClass in XIB, adding it to UITableView like class RestaurantsTableView: UITableView { override func awakeFromNib() { self.register(UINib(nibName: "RestaurantTableViewCell", bundle: nil), forCellReuseIdentifier: "restaurantCell") } } and everything works fine, now I would like to use this CustomTableViewClass as UIView in some other UIViewController , but I do not get how to properly override its init(coder aCoder: NSCoder) function, cause I do not need one for

Invalid number of rows in section even though I delete in order

天涯浪子 提交于 2020-08-09 08:16:21
问题 I have a tableView in which the user can delete cells . This is in cellForRowAt in class WhishlistTableViewController: UITableViewController : cell.deleteWishCallback = { [unowned self] deletedCell in print("delete with callback") guard let indexPath = tableView.indexPath(for: deletedCell) else { return } self.deleteWishDelegate?.deleteWish(indexPath, currentWish.wishCounter) self.wishData.remove(at: indexPath.row) tableView.deleteRows(at: [indexPath], with: .right) print("removed from

iOS - How To Give A Peek At The “Swipe To Delete” Action On A Table View Cell?

≯℡__Kan透↙ 提交于 2020-08-08 05:11:46
问题 When a certain Table View Controller displays for the first time, how to briefly show that the red “swipe to delete” functionality exists in a table row? The goal of programmatically playing peekaboo with this is to show the user that the functionality exists. Environment: iOS 11+ and iPhone app. Here's an image showing the cell slid partway with a basic "swipe to delete" red action button. A fellow developer kindly mentioned SwipeCellKit, but there’s a lot to SwipeCellKit. All we want to do

UITableView custom cell - How to keep cornerRadius in edit mode

自闭症网瘾萝莉.ら 提交于 2020-08-08 04:01:54
问题 I implemented a tableview with custom cells. The cells have their cornerRadius set to 2. Everything displays just fine until I enter edit mode. When the delete button appears, it's corner radius is 0. How can I make the delete button have a cornerRadius too? I tried this without any luck: func tableView(tableView: UITableView, willBeginEditingRowAtIndexPath indexPath: NSIndexPath) { let cell = tableView.cellForRowAtIndexPath(indexPath) cell!.editingAccessoryView?.layer.cornerRadius = 2 } The

how to disable UserInteraction for UITableview cell but not in custom button on cell

拈花ヽ惹草 提交于 2020-08-06 12:13:58
问题 How to disable UserInteraction for UITableview cell but not in custom button on that cell.. I am creating a button using : UIButton *dayButton = [UIButton buttonWithType:UIButtonTypeCustom]; [dayButton setFrame:CGRectMake(201, 0, 30, 35)]; [dayButton addTarget:self action:@selector(selectDayView) forControlEvents:UIControlEventTouchUpInside]; [dayButton setBackgroundImage:[UIImage imageNamed:@"86-camera.png"] forState:UIControlStateNormal]; dayButton.userInteractionEnabled=YES; [cell

How to reload programmatically moved row?

守給你的承諾、 提交于 2020-08-04 04:32:36
问题 Frustrating fact: After calling tableView:moveRowAtIndexPath:toIndexPath: , tableView:cellForRowAtIndexPath: doesn't get called for that row. Call reloadRowsAtIndexPaths:withRowAnimation: after or before tableView:moveRowAtIndexPath:toIndexPath: within UITableView updates block also doesn't work: it raises Inconsistency error . I see 2 workarounds: delete+insert instead of move or do reload within another updates block. My question is: is there some other way to reload and move UITableView's

Swift Change the tableviewcell border color according to data

我与影子孤独终老i 提交于 2020-08-04 03:39:29
问题 I have written a code for making the cell border color change according to inStock or outStock , if it is inStock it will be red border else it would be green, but I it is not working for me, I put it in willDisplayCell and here is my code : func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath){ cell.backgroundColor = UIColor.clear cell.contentView.backgroundColor = UIColor.clear let whiteRoundedView : UIView = UIView(frame: CGRect(x:10,y:

Swift Change the tableviewcell border color according to data

核能气质少年 提交于 2020-08-04 03:39:09
问题 I have written a code for making the cell border color change according to inStock or outStock , if it is inStock it will be red border else it would be green, but I it is not working for me, I put it in willDisplayCell and here is my code : func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath){ cell.backgroundColor = UIColor.clear cell.contentView.backgroundColor = UIColor.clear let whiteRoundedView : UIView = UIView(frame: CGRect(x:10,y:

How does data source and delegate in UITableView works?

前提是你 提交于 2020-08-02 05:04:44
问题 I am new in ios development. When I use UITableView, I implement data source and delegate together. like the following two methods: // Data source method - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section // Delegate method - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath However, if I am understand correctly, table view does not hold any data, and it only store enough data to draw the rows that are currently

How does data source and delegate in UITableView works?

柔情痞子 提交于 2020-08-02 05:04:37
问题 I am new in ios development. When I use UITableView, I implement data source and delegate together. like the following two methods: // Data source method - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section // Delegate method - (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath However, if I am understand correctly, table view does not hold any data, and it only store enough data to draw the rows that are currently