uitableview

How to run imagePicker in tableViewCell

和自甴很熟 提交于 2021-02-07 19:32:04
问题 I have a tableView with a cell. In this cell I have an imageView, and a button covering it. The button has an IBAction. When tapped, the button is supposed to summon the imagePicker. The IBAction code is located in the cell subview. @IBAction func MyStatusImageButtonAction(sender: AnyObject) { // Select Image let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary imagePicker.allowsEditing = false self

How to run imagePicker in tableViewCell

对着背影说爱祢 提交于 2021-02-07 19:31:14
问题 I have a tableView with a cell. In this cell I have an imageView, and a button covering it. The button has an IBAction. When tapped, the button is supposed to summon the imagePicker. The IBAction code is located in the cell subview. @IBAction func MyStatusImageButtonAction(sender: AnyObject) { // Select Image let imagePicker = UIImagePickerController() imagePicker.delegate = self imagePicker.sourceType = UIImagePickerControllerSourceType.PhotoLibrary imagePicker.allowsEditing = false self

How to get the index in Results of a certain Realm object?

梦想的初衷 提交于 2021-02-07 19:14:30
问题 Here is an example. class Person: Object { dynamic var id dynamic var name } // does this work? let sortedPeople = realm.objects(Person).sorted("id") let Dave = realm.objects(Person).filter("id=5") // at what index does Dave reside in sortedPeople? The reason I need to find out about this is coz I have a UITableView that is set to the sortedPeople, but I need to store the last visible row viewed. The sortedPeople array changes frequently. So, if I can find out the index in the sortedPeople of

Send Row and Section through Tag in Button Swift

风格不统一 提交于 2021-02-07 14:49:07
问题 I have this inside cellForRowAtIndexPath cell.plusBut.tag = indexPath.row cell.plusBut.addTarget(self, action: "plusHit:", forControlEvents: UIControlEvents.TouchUpInside) and this function outside: func plusHit(sender: UIButton!){ buildings[sender.tag].something = somethingElse } Is it possible to send the indexPath.row and indexPath.section , or some alternative?? Thanks! EDIT I approached it like this: My Custom Button class MyButton: UIButton{ var myRow: Int = 0 var mySection: Int = 0 }

how to make swipeable UItableview header to show delete button like cells

与世无争的帅哥 提交于 2021-02-07 14:42:51
问题 I have a custom header which is sub class of UITableViewHeaderFooterView I want to add the delete button similar to UITableViewCell to this header, I have gone through the internet and found some open source libraries to create swipeable cell which only extend the functionality of UITableviewCell which actually I don't need for the time, What I actually want is to create a swipeable header View to show the delete button on swipe. 回答1: There is not out of the box solution for this. However we

how to make swipeable UItableview header to show delete button like cells

房东的猫 提交于 2021-02-07 14:41:03
问题 I have a custom header which is sub class of UITableViewHeaderFooterView I want to add the delete button similar to UITableViewCell to this header, I have gone through the internet and found some open source libraries to create swipeable cell which only extend the functionality of UITableviewCell which actually I don't need for the time, What I actually want is to create a swipeable header View to show the delete button on swipe. 回答1: There is not out of the box solution for this. However we

Custom view for Drag and Drop

本秂侑毒 提交于 2021-02-07 07:31:34
问题 I have set up my UITableView to use the new Drag and Drop APIs. if #available(iOS 11, *) { self.tableView.dragDelegate = self self.tableView.dropDelegate = self self.tableView.dragInteractionEnabled = true navigationController?.navigationBar.prefersLargeTitles = false } Now, I implemented the method below to be able to use custom views for the d&d. @available(iOS 11.0, *) func dragInteraction(_ interaction: UIDragInteraction, previewForLifting item: UIDragItem, session: UIDragSession) ->

Custom view for Drag and Drop

元气小坏坏 提交于 2021-02-07 07:31:02
问题 I have set up my UITableView to use the new Drag and Drop APIs. if #available(iOS 11, *) { self.tableView.dragDelegate = self self.tableView.dropDelegate = self self.tableView.dragInteractionEnabled = true navigationController?.navigationBar.prefersLargeTitles = false } Now, I implemented the method below to be able to use custom views for the d&d. @available(iOS 11.0, *) func dragInteraction(_ interaction: UIDragInteraction, previewForLifting item: UIDragItem, session: UIDragSession) ->

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

心不动则不痛 提交于 2021-02-07 07:15:20
问题 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:)

…衆ロ難τιáo~ 提交于 2021-02-07 07:14:46
问题 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