I am trying to change the default left minus icon for a cell in edit mode.
I tried everything.
I am already able to change the Delete confirmation button on the right, I need only to change the left icon.
I tried to create a custom interface cell and added a custom image on the left side, then I have added this code in my view controller.
override func tableView(tableView: UITableView, editingStyleForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCellEditingStyle {
return UITableViewCellEditingStyle.None
}
Adding that code gives me a way to hide the minus default icon and showing my own image.
The problem is that the space for the default icon remains anyway :(
I do not know what else to do. I tried using constraints in my custom cell interface, but it does not fix the issue at all.
Also when using that piece of code anyway, not only the icon goes away (that's fine apart from the white space that it leaves) but also does not show anymore the right actions when swiping. Only the drag and drop feature reamains active.
func tableView(tableView: UITableView, shouldIndentWhileEditingRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return false
}
add this function so the rows wont indent while editing
Related
I have Trailing Swipe actions set up for my table view. And everything works fine, until I delete a cell, and then the cell below it has its trailing swipe actions overlapping with its cell when it's swiped over, rather than swiping over the actual cell to present the trailing swipe actions.
Some notes that I've discovered:
- Only the cell directly below a deleted one is affected.
- The cell is only affected for a little bit of time, or until the user scrolls the table view up and down. But it's still a big issue in actual use given that typically people will delete their cells in rapid succession.
I've taken a screen recording an put it on Youtube:
https://www.youtube.com/watch?v=a_8JuLFrfyE&feature=youtu.be
I have tried controlling when the table view enters and exits its updating via .beingUpdates and .endUpdates, but that made no difference.
And I tried reloading the problematic cell, but that didn't help and made the cell flash. I also tried scrolling the table view just slightly after a deletion, but that didn't help either.
func tableView(_ tableView: UITableView, trailingSwipeActionsConfigurationForRowAt indexPath: IndexPath) -> UISwipeActionsConfiguration? {
// The configuration of the cells isn't very important, but it's more so an issue just when deleting cells that have trailing swipe actions.
}
Im trying to include a tap to open screen on my playground that then allows users to see my chart. I want them to first tap through 3 or 4 screens with different information before loading to my main page.
Ive tried searching up tutorials (Im new at this), but cant find any that help me.
So this is the code to show my table view and need help implementing the tap screens
class HOCMasterViewController: UITableViewController {
override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return reasons.count
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
var cell: UITableViewCell!
cell = tableView.dequeueReusableCell(withIdentifier: "Cell")
My table appears, just need to add the UI for the tap screens!
First of all the information screens that you need users to tap through. How are they being displayed? Are you using simple UIViews? Kindly give us some info on that? If you are using different UIViews on which you are showing information, then I would simply hide the previous UIView/ remove it from superView and add the next UIView and so on!
So your playground loads and when you tap on the screen by using a UITapGestureRecognizer and in the selector function you count the taps and according to each tap, you can hide or show the UIViews / or animate the constraints / frames of each UIView. Then after 3 taps you can show the TableViewController.
Kindly provide us with the information screen code.
I will try to explain my problem with the help of pictures :
Firstly, I just added an UITableView to my UIViewController. I selected it to show its frame and there was no problem.
Next, when I connect my button to my UIViewController, my UITableView gets smaller.
I selected it to see that the frame doesn't match with the contents. I noticed that the tableview reduces exactly of 64 (44 from the UINavigationBar + 20 from the bar with the battery)
At the beginning, I thought it was juste a display problem from XCode, but next when I tried to run it with cells, the problem still exist.
So I put a UIContainerView in my UIViewController and my tableView in the controller of the container. XCode display properly my table view, but when in run it, I get the same problem.
Thank you in advance,
Sorry for my english.
The problem is that your containing view controller's Adjust Scroll View Insets is checked (in its Attributes inspector). Uncheck it.
You can use this function to explicitly set the size of your cell.
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
}
Description:
I have a list of UITableViewCells that have each have a UICollectionView with X amount of UICollectionViewCells (see image below for more clarity)
The idea behind this is to be able to implement sections with a header on top and a horizontal scrolling UICollectionView
Everything is working great, except when I try to focus the UICollectionViewCells (aka: CategoryCell). The UITableViewCell gets focused and highlights all the content making it impossible to focus any of the UICollectionViewCells.
What I've tried:
According to other posts the fix for this would be deactivate User Interaction and/or set the selection style to none on the UITableViewCell:
cell.selectionStyle = UITableViewCellSelectionStyle.None
and to enable User Interaction on the UICollectionViewCell instead.
Here are posts that talk about it:
UITableViewCell with UITextField losing the ability to select UITableView row?
How can I disable the UITableView selection highlighting?
I've attempted to implemen these solutions without success.
Question:
What step did I miss? Does the fix not work on tvOS? How do I focus my UICollectionViewCell that is in a UICollectionView that is in a UITableViewCell?
More:
Image showing my UITableViewController and all it's contents from my StoryBoard.
The problem is most likely that your table view cells are returning true to canBecomeFocused. You can disable that by either implementing the UITableViewDelegate method tableView(_, canFocusRowAt:) to return false, or by subclassing UITableViewCell and returning false from canBecomeFocused.
The focus engine will try to focus on the top-most view that returns true from canBecomeFocused, which is why it can't find your collection view cells: they're "hidden" inside the focusable table view cells. If you disable focus on the table view cells, then the focus engine will be able to find your collection view cells.
override func tableView(tableView: UITableView, canFocusRowAtIndexPath indexPath: NSIndexPath) -> Bool {
return false
}
I have a table list that is order by create date using a Realm database. I am trying to find a way to let the user when using the app, drag a row (cell) to a new position in the table.
I was hoping something like this for Deletes could be used:
func tableView(tableView: UITableView, commitEditingStyle editingStyle: UITableViewCellEditingStyle, forRowAtIndexPath indexPath: NSIndexPath)
{
if (editingStyle == UITableViewCellEditingStyle.Delete)
{
}
}
Unfortunately, there is no editing mode (like the one in UITableView) in WKInterfaceTable. Also, because there are no drag gestures exposed in WatchKit, there is no way to duplicate this functionality in the current version.
One approach might be to add your own control that toggles an edit mode, then expose buttons in each cell that move the row up or down. This would require a bit of work, and actually, I'm not sure it would be a good user experience due to the limited screen real estate.