0
votes

I have a problem since this morning and I'm going insane not to find the solution.

Here is my problem :

I have a view controller that contains an UItableView and some other stuff... no problem with that part : my tableView call my webService, and reload the filled tableView. But when I want to trigger the execution of a segue on the selection of an UItableViewCell nothing happens.

My tableView DataSource and Delegate are set :

ViewController referencing outletObservatoireView.h

I tried several methods but nothing works :

1) Directly link the segue on the cell 2) Declare the segue on the viewController and call it with "performSegue" when "didSelectRowAtIndexPath" is called 3) Restart Xcode (yes, I was desperate)

But, as I said it before, the delegate and datasource methods of my tableView are correctly called except "didSelectRowAtIndexPath"

Does someone already encounter this problem and found the solution ?

EDIT :

Here is the implementation of the tableView dataSource methods

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    // Return the number of sections.
    return 1;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
    // Return the number of rows in the section.
    return campagneList.count; //return 2 at execution
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
    [self performSegueWithIdentifier:@"observatoireSegue" sender:self];
    NSLog(@"test didSelectRowAtIndexPath");
}
1
Can you show your didSelectRowAtIndexPath ? A common mistake is also to implement didDeselectRowAtIndexPath instead.streem
What's your implementation for - (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section and - (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView ? If one of them is returning 0 cellforrow will never get called.The dude
Why are you subclassing from ViewController? Shouldn't you be subclassing from UIViewController? Or even better, if the table is the only thing on the screen subclass from UITableViewController.Fogmeister
Make sure that cell selection is not turned off for your tableview in the storyboard.jamihash
If the subclassing Fogmeister suggested isn't the problem, then you might try taking a closer look at your Storyboard and IBOutlet of your tableView. It might be worth the shot to disconnect the tableView, remove the property in code and reconnect the IBOutlet by creating a new property and set the delegate/datasource again. When switching controllers, errors in this area can occur.Michael

1 Answers

0
votes

You should not subclass ObservatoireView from ViewController class. Apparently compiler won't throw any error or warning. If you do so, message communication will not happen from your Class to Controller. Hence it will work if you change parent class to UIViewController or UITableViewController .

@interface ObservatoireView :UIViewController <yourprotocols> 

//Rest of code goes here

@end