I'm stuck in a problem: I have a project with a lot of segues and vc's. After I was changing some ViewController to a TableViewController the segue to this won't work anymore. I created a blank TableViewController from Cocoa-Class as Subclass of UITableViewController. I'm using Storyboard and IB.
In HomeViewController I have a tableView. The Cell has a protocol HomeTableViewCellDelegate with some functions. One of them is didTapPostImage(post: PostModel). In the Cell I set a tapGesture to the PostImage:
func addTapGestureToPostImage(){
let tapGesture = UITapGestureRecognizer(target: self, action: #selector(handleTapPost))
postImageView.isUserInteractionEnabled = true
postImageView.addGestureRecognizer(tapGesture)
print("TEMP -> TapGesture active")
}
@objc func handleTapPost(){
guard let post = post else { return }
print("TEMP -> post image clicked")
delegate?.didTapPostImage(post: post)
}
In awakeFromNib I call the function of course.
In the HomeViewController I have an extension
extension NewsFeedViewController: HomeTableViewCellDelegate {
func didTapPostImage(post: PostModel) {
self.post = post
performSegue(withIdentifier: "HomeToSinglePostViewController", sender: self)
print("TEMP -> performSegue")
}
}
and I'm overriding prepare like:
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
if segue.identifier == "HomeToSinglePostViewController" {
print("TEMP -> prepare")
let singlePostVC = segue.destination as! SinglePostViewController
singlePostVC.post = self.post
}
}
I've tried to rename the segue identifier - but that don't work, too. In prepare and in the extension I have some other segues to other vc's that all are working. When I navigate to another VC to access the new SinglePostViewController the segue doesn't work, too. The SinglePostViewController is unreachable from everywhere - but I get no error or hint.
In my log I can see that TapGesture, prepare-part and perform-part are called!
Before I created the TableViewController with class it was a ViewController with a ScrollView and a TableView inside - with that all was fine! What I'm missing? Tried so many things but no luck!
My HomeViewController is nested in a Navigation Controller - the SinglePostViewController not ( but the old one wasn't, too )
Hope someone has an answer. I'm using Xcode 14.2 with Swift 5 - InterfaceBuilder Project.
Kind regards and thanks in advance!