last day (14 days later) » 

12:44 PM
0
Q: didSelectRowAtIndexPath not being called in ios swift

user2413621I am working on a iOS project in swift language. It is a already written code and I am adding new features. There is a class say A: UITableViewController and has a function cellForRowAtIndexPath override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITa...

 
Show the didSelectRowAtIndexPath function from class A. Also, is selection enabled on the tableView? Is your class A the tableviews delegate?
 
didSelectRowAtIndexPath now just have a print statement.(How should I add to go to load new view) Class A is tableviews delegate.
 
Still, show the code. It is one of three things - your function prototype is wrong, the delegate isn't set or selection isn't enabled on the table
 
override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { println("Hello") }
I think the error is in cellForRowAtIndexPath
 
Do you see a cell in your tableView? If so then there isn't anything wrong with cellForRowAtIndexPath. Have you checked the tableView has selection enabled in interface builder?
 
12:46 PM
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {

if (indexPath.section > 0) {
#do something
}
editing = self.tableView.editing
}

return B(#Parameters)
}
 
Showing non code isn't particular helpful.
Is your tableView created in a storyboard? Have you checked that selection is enabled?
 
this is the basic structure
 
Ok, but if you ask me is there something wrong all I can say is "yes, that is gibberish".
The basic structure is fine as long as B is a uitableviewcell subclass. If you see content in the table then this method is working.
 
yes it is
 
Note that there are two settings for selection - one for editing mode and one for non editing mode
 
12:51 PM
in this editing is set to false
editing = false
editing = self.tableView.editing
 
Did you check that selection is enabled in the storyboard or nib file?
You keep not answering that question
 
I will tell you the work flow
A tabBarController
 
I don't really care. Please! Just check the tableView in interface builder and look at the switch to see if selection is turned on
 
I cant see any tableview in interface builder
 
Tableviews work - your method looks correct so either the delegate isn't set, selection isn't enabled
Ok, then if the tableView is being created programatically then you need to set the selection property
 
12:59 PM
how can i set it?
 
It should be yes by default, but perhaps it has been set to no
Or set a breakpoint - perhaps your function is being called
And have you verified that your class a is set as the tableviews delegate
 
yes
var allowsSelection: Bool
Were to add this code?
It may be a dumb question... i am new to this..your help will be greatly appreciated
 
1:29 PM
u dere?
 
1:44 PM
?
 

last day (14 days later) »