Basically I have a tableView in my viewController showing some calendar events and upon clicking a row I want to show the default EKEventViewController that presents the event in a standard way.
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let eventViewController = EKEventViewController()
eventViewController.event = lastEvents[indexPath.row]
eventViewController.allowsCalendarPreview = true
show(eventViewController, sender: nil)
}
This works, however there's a strange dark background that appears "under" this EKEventViewController. I have to get rid of this background.
I've uploaded an example application that exhibits this behavior.
Additionally, after the EKEventViewController has been shown and popped, there remains a bar at the bottom (where the "Delete Event" button was).
Edit: I forgot to mention that there's a debug message telling me Unable to simultaneously satisfy constraints. However it's strange since it's not really my layout. All I'm doing is showing this viewController.
Here's how it looks:
Related
I have a tableViewController with custom cells that each contain a textField. Cells are added to the tableView by clicking an 'Add' button which calls the insertRows(at:with:) method. The cells have a reuseIdentifier and are being reused.
The issue:
Given the user has added a bunch of rows and is editing a textField in one of the bottom rows, when the user tries to scroll to the top by tapping the status bar at the top of the screen, then the tableView jumps / glitches on the first tap, but then scrolls to the top (as expected) after the user taps the status bar a second time.
Note: this jump / glitch doesn't occur when the textField being edited is the first textField to be edited in the tableView, it only occurs from the second edit onwards.
The goal: For the tableView to scroll to the top when the status bar is tapped, without hiding the keyboard.
Things I've tried
Manually setting tableView.scrollsToTop = true
Adding tableView.beginUpdates() before calling insertRows(at:with:), and endUpdates() after
Resigning first responder when textField finished editing
Searching the web for many hours to understand why this is happening, to no avail
#IBAction func addButtonTapped(_ sender: Any) {
let indexPath = IndexPath(row: cells.count, section: 0)
cells.append(cell(text: ""))
tableView.insertRows(at: [indexPath], with: .none)
}
override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "customCellIdentifier", for: indexPath) as! TableViewCell
return cell
}
Attached GIF shows the jump / glitch when the user taps the status bar for the first time, followed by the expected behaviour when the status bar is tapped for the second time.
TableView Jump / Glitch
Any help would be most appreciated. Thanks in advance!
In UITableView, when tapping and holding a cell and (without releasing this cell) switching to another screen in tab bar and returning to the initial one, the cell remains highlighted (not selected) and if tapping on another cell, the first one gets selected.
Upon tapping and holding the first cell, tableView(_ tableView: UITableView, didHighlightRowAt indexPath: IndexPath) is called for the first cell. So far it is how it should be.
Upon tapping on another cell (after returning to the screen), tableView(_ tableView: UITableView, didUnhighlightRowAt indexPath: IndexPath) is called for the first cell. And then all methods for selection for the first cell.
Is there a way to remove this behaviour? And upon returning to the screen have no highlighted cells.
cell.setHighlighted(false, animated: false) doesn't work. Yes, it removes highlighting, but selection methods are again called for the first cell.
Have you tried to implement shouldHighlightRowAt and return false?
From the docs for tableView(_:shouldHighlightRowAt:):
Asks the delegate if the specified row should be highlighted.
I want to customise the delete indicator for a UITableView in editing mode.
Since I can't seem to find a way to customise the appearance style of the delete button shown in the first image, I've created my own animation with my own button.
I have deactivated the red standard button using:
func tableView(_ tableView: UITableView, editingStyleForRowAt indexPath: IndexPath) -> UITableViewCellEditingStyle {
return .none
}
Now my question: How do I realize the same behaviour as the standard button? If you press the red button, it invokes a swipe left on the cell showing the wanted delete button.
Help is very appreciated.
In my storyboard, I have a UITableViewController (embedded in a UINavigationController) on which I have added a CANCEL button as a Left Bar Button Item.
At runtime, the CANCEL button doesn't appear, but an EDIT button does.
I haven't explicitly added the EDIT button and have kept the default implementation of the edit function in its disabled state thus:
// Override to support conditional editing of the table view.
override func tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath) -> Bool {
// Return false if you do not want the specified item to be editable.
return false
}
I've looked into ways to hide the EDIT button and this line of code works:
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
self.navigationItem.leftBarButtonItem = nil
}
... in that it hides the EDIT button. But, it also hides the CANCEL and all other buttons on the left!
I have discovered code that explicitly shows the EDIT button, i.e.:
self.navigationItem.leftBarButtonItem = self.editButtonItem
But cannot find an equivalent for CANCEL.
So, is there a way to hide the EDIT button but show the CANCEL button?
--- UPDATE #1 ---
I have already connected the Cancel button to my class code via an IBOutlet per attached screenshot.
--- UPDATE #2 ---
I have now ensured that
tableView(_ tableView: UITableView, canEditRowAt indexPath: IndexPath)
and
tableView(_ tableView: UITableView, commit editingStyle: UITableViewCellEditingStyle, forRowAt indexPath: IndexPath)
are commented out. So, as far as I can tell, there is nothing about this TableViewController that enables editing of rows. Yet, the 'EDIT' button still appears and obfuscates my 'CANCEL' button.
leftBarButtonItems is a slightly different thing than leftBarButtonItem
It sounds like your cancel button has been added to the leftBarButtonItems of the navigationItem for your view controller, but you don't have a reference to it in your class. Create an IBOutlet reference for it and you should be able to set it explicitly as the leftBarButtonItem in the same way as you are the edit button.
Facepalm time.
I had copied over a method from another class which had the edit button explicitly displayed the following line:
self.navigationItem.leftBarButtonItem = self.editButtonItem
Deleting this line removes the EDIT button at run time.
I've set the cell accessory to "disclosure indicator" and I have linked that cell with an ctrl - click ("show (eg. push)") to another view. But when I test the app, the cell just becomes grey and nothing more (look at the screenshot). I want this to behave like a Settings-like view.
any hints?
thx, Tim
The disclosure indicatoris just that; an indicator, not a button, so when you make a segue from a cell , with or without a disclosure indicator, it needs to be a "selection" segue. The "accessory action" section of the choices you get when making the segue should be use if you have a "detail disclosure" button, and you want the segue triggered by touching the button itself.
if you want to navigate by code means try this method.
func tableView(_ tableView: UITableView, accessoryButtonTappedForRowWith indexPath: IndexPath) {
//navigateTo your viewController
}
You can find this in TableView Delegate.