Hi guys, I have a view controller. Within this view controller, I have a subview named SearchUserSubView containing a table view.
Since I am not able to push to another view controller within this view, I tried to do following thing:
class SearchUserSubView:UIView {
...
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let userCell = tableView.cellForRow(at: indexPath) as! SearchUserTableViewCell
let userObject = userResultArray[indexPath.row]
// if the profile image is not loaded, don't allow clicking on the cell
if(userCell.profileImageView.image == nil) {
return
}
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let searchContentController = storyBoard.instantiateViewController(withIdentifier: "searchContent") as! SearchContentViewController
searchContentController.showProfileViewController(userObject: userObject, userProfileImage: userCell.profileImageView.image!)
}
I am trying to call the showProfileViewController method, defined in my view controller class. And it is actually called:
func showProfileViewController(userObject: User, userProfileImage: UIImage) {
let storyBoard : UIStoryboard = UIStoryboard(name: "Main", bundle:nil)
let selectedUserController = storyBoard.instantiateViewController(withIdentifier: "selectedUserProfile") as! SelectedUserProfileViewController
selectedUserController.userObject = userObject
selectedUserController.userProfileImage = userProfileImage
let navController = storyBoard.instantiateViewController(withIdentifier: "searchContentNav") as! UINavigationController
navController.pushViewController(selectedUserController, animated: true)
}
Whatever I do here, nothing is pushed towards the SelectedUserProfileViewController.
Can anyone tell me, why this is the case?