Reputation: 111
I am using the following tutorial from ray http://www.raywenderlich.com/913/sqlite-101-for-iphone-developers-making-our-app
im getting everything to work except for the detail view to populate from didselectrow
This is what he has
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
if (self.details == nil) {
self.details = [[[FailedBanksDetailViewController alloc] initWithNibName:@"FailedBanksDetailViewController" bundle:nil] autorelease];
}
FailedBankInfo *info = [_failedBankInfos objectAtIndex:indexPath.row];
_details.uniqueId = info.uniqueId;
[self.navigationController pushViewController:_details animated:YES];
[self performSegueWithIdentifier:@"testID" sender:self.view];
}
however it is not working with storyboards
Can someone please help me, I searched everywhere for an answer!!!
Upvotes: 1
Views: 1724
Reputation: 437552
A couple of options:
You could supply the scene you're transitioning to with a "storyboard id" (you do this in Interface Builder) and then use instantiateViewControllerWithIdentifier
instead of initWithNibName
.
If you use cell prototypes in your storyboard, you don't need a didSelectRowAtIndexPath
method at all, and instead just add a segue from your cell prototype to the next scene. You then write a prepareForSegue
method in which you pass the uniqueId
to the next scene.
That prepareForSegue
might look like:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if ([segue.identifier isEqualToString:@"DetailsSegue"])
{
NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
FailedBankInfo *info = [_failedBankInfos objectAtIndex:indexPath.row];
[(FailedBanksDetailViewController *)segue.destinationViewController setUniqueId:info.uniqueId];
}
}
Obviously, replace DetailsSegue
with whatever name you supply for your segue's storyboard id.
Upvotes: 0
Reputation: 119031
Currently your using code for bob the NIB and the storyboard. Choose 1 and stick with it. If you go with storyboard, just perform the segue then handle the prepareForSegue:sender:
to configure the destination view controller.
Upvotes: 1
Reputation: 18470
try:
self.details = [self.storyboard instantiateViewControllerWithIdentifier:@"FailedBanksDetailViewController"];
Where FailedBanksDetailViewController
is the identifier
for the view controller in your main storyboard.
And since you are using http://www.raywenderlich.com you can take a look here for a storyboard example.
Upvotes: 0