Hi everyone,
I've been trying to figure this issue out for a REALLY long time and any bit of help would be amazing, especially since I'm new to Objective-C.
Currently I'm making an app that has a tabBarController with one of the pages with a tableView which navigates to an info page of the object in that row.
Right now, what it does is initialize the table, but when I click on the row that I want, it crashes when I try to get to the next page. According to the debugger, its finding the name of the viewController, but not cannot load the next page.
Here's some code:
This is just the initialization of the tableview.
This is the initWithNibName for one of the viewControllers (which is the same for the rest)
Let me know if you need more code to understand the issue further.
Thanks!
I've been trying to figure this issue out for a REALLY long time and any bit of help would be amazing, especially since I'm new to Objective-C.
Currently I'm making an app that has a tabBarController with one of the pages with a tableView which navigates to an info page of the object in that row.
Right now, what it does is initialize the table, but when I click on the row that I want, it crashes when I try to get to the next page. According to the debugger, its finding the name of the viewController, but not cannot load the next page.
Here's some code:
This is just the initialization of the tableview.
Code:
- (void)viewDidLoad {
if (!pages)
{
pages = [[NSArray alloc] initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer", nil];
}
//menuLIst == sitesArray
for (NSString *pageName in pages)
{
[self.menuList addObject:[NSMutableDictionary dictionaryWithObjectsAndKeys:
NSLocalizedString([pageName stringByAppendingString:@"Title"], @""), kTitleKey,
NSLocalizedString([pageName stringByAppendingString:@"Explain"], @""), kDetailKey,
nil]];
}
NSArray *sites = [[NSArray alloc] initWithObjects:@"CSLP", @"NSLS", @"LSPA", @"SIOP", @"Transfer Vision Program ", nil];
self.sitesArray = sites;
UIImage *cslp = [UIImage imageNamed:@"CSLP LOGO.png"];
UIImage *nsls = [UIImage imageNamed:@"NSLS LOGO.png"];
UIImage *lspa = [UIImage imageNamed:@"LSPA LOGO.png"];
UIImage *siop = [UIImage imageNamed:@"SIOP LOGO.png"];
UIImage *transfer = [UIImage imageNamed:@"TRANSFER LOGO.png"];
NSArray *images = [[NSArray alloc] initWithObjects: cslp, nsls, lspa, siop, transfer, nil];
[sites release];
self.imagesArray = images;
}
Code:
-(void) tableView:(UITableView *) tableView didSelectRowAtIndexPath: (NSIndexPath *) indexPath
{
//NSInteger row = [indexPath row];
NSMutableDictionary *rowData = [self.menuList objectAtIndex:indexPath.row];
UIViewController *targetViewController = [rowData objectForKey:kViewControllerKey];
if (!targetViewController)
{
// The view controller has not been created yet, create it and set it to our menuList array
NSLog(@"pages objectAtIndex: %@", [[pages objectAtIndex:indexPath.row] stringByAppendingString:@"ViewController"]);
NSString *viewControllerName = [[pages objectAtIndex:indexPath.row] stringByAppendingString:@"ViewController"];
NSLog(@"ViewControllerName: %@", viewControllerName);
targetViewController = [[NSClassFromString(viewControllerName) alloc] initWithNibName:viewControllerName bundle:nil];
NSLog(@"targetViewController: %@", targetViewController);
SSARC_App_2AppDelegate *delegate = (SSARC_App_2AppDelegate*)[[UIApplication sharedApplication] delegate];
[[delegate orgsNavigationController] pushViewController:targetViewController animated:YES];
[delegate release];
[rowData setValue:targetViewController forKey:kViewControllerKey];
}
[targetViewController release];
}
This is the initWithNibName for one of the viewControllers (which is the same for the rest)
Code:
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
if (!(self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]))
return nil;
self.title = NSLocalizedString(@"CSLPTitle", @"");
return self;
}
Let me know if you need more code to understand the issue further.
Thanks!