last day (14 days later) » 

10:19
-1
Q: Swift: prepareforsegue method is not called

Dhivya SundaramI have a UITableView along with UISearchBar. I displayed some coredata value such as name of employees in the tableview. If I select the row on a particular employee name, the details of the employee should be displayed in the another view controller, and I did this using this "override func prep...

can you show your code of cellforRowat and didselectRow
@Anbu - please wait I will add my code here
@DhivyaSundaram - ya sure
@praveen - yes I used indexpath
@Anbu.Karthik pls find the image of code block
@DhivyaSundaram - I asked your your code of cellforRowat and didselectRow, problem in didselect or tap action problem not in segue
10:19
@PraveenKumar - segue connection is common between the tableview & the detail view controller.
@DhivyaSundaram - dont add the image add the code always
@Anbu.Karthik - i didnt use didselectrowatindexpath, am implementing the navigation using the segue. And also tried with the didselectrowatindexpath it is not called.
@DhivyaSundaram - dear sister I think you used any Gesture or button action in your cellforRowat can you show ur code , its better to find the excat issue
@DhivyaSundaram - we dont know what your project contains, if you add some additional information it is better to identify the issye
@Anbu.Karthik - nothing i used in cellForRow, wait let me add the code
10:21
hi
pls find my code
i have pasted it
ok how do select the particular cell
i didnt get u
who downvoted my question? may i know the reason
ya how do u select the any cell
in didselect or else where
i am not assign the downvotw
let object : Any
if(searchActive){
object = self.filteredEmployees[(indexPath?.row)!]
}
else{
object = self.employees[(indexPath?.row)!]
}
10:25
simply u can select how do u do in the didselect
self.prepare(for: "", sender: object)
add this code into didselectrowatindex function
@sabs : actually i implemented the same code in didselect but unfortunately the didselectmethod is not calling.. I dont know the reason
better
is this possible to attach your project
i wil check
yeah sure
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController
//controller.detailItem = object
controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
controller.employees = sender as! EmployeeDetails
}
10:28
@sabs: oh like this i need to do
@Sabs - problem not in here
self.prepare(for: "", sender: object) // Mentioned the segue name in ""
else simple use
@SABS- OK
@DhivyaSundaram - Did you set the UITableViewDelegate
10:30
self.performSegue(withIdentifier: "yoursegueName", sender: object) // use self
@sabs- ofcourse, if not how could i display the names in tableview
For displaying the names in tableview will be handled by UITableViewDataSource
To performing the action we have to use UITableViewDelegate.
@sabs
@sabs- yeah but y the segue navigation is not works
how add the project here
@DhivyaSundaram - Sorry, use "self.performSegue(withIdentifier: "yoursegueName", sender: object)" instead of this "self.prepare(for: "", sender: object)". Anbu was correct.
@sabs - where to add that code
10:36
func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
let object : Any
if(searchActive){
object = self.filteredEmployees[(indexPath?.row)!]
}
else{
object = self.employees[(indexPath?.row)!]
}
self.performSegue(withIdentifier: "yoursegueName", sender: object)
}
Next
@Sabs- ok
override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
let controller = (segue.destination as! UINavigationController).topViewController as! DetailViewController
//controller.detailItem = object
controller.navigationItem.leftBarButtonItem = splitViewController?.displayModeButtonItem
controller.navigationItem.leftItemsSupplementBackButton = true
controller.employees = sender as! EmployeeDetails
}
@sabs - ok, let me try
If you don't get the solution, Send me the project to my mail "[email protected]"
@sabs- ok

last day (14 days later) »