views:

105

answers:

1

Ok, Here is the code in my AppDelegate that loads the Schedule nib.

Schedule *newestVideoController = [[Schedule alloc] initWithNibName:@"Schedule" bundle:nil];
    newestVideoController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"Schedule" image:[UIImage imageNamed:@"app-icon_2_newest.png"] tag:2];
    NSArray *controllers = [NSArray arrayWithObjects:navController, newestVideoController, nil];
    mainController.viewControllers = controllers;

Now here is my header file for schedule.

#import <UIKit/UIKit.h>
#import "AnotherViewController.h"


@interface Schedule : UITableViewController
<UITableViewDelegate, UITableViewDataSource>    {
    NSArray *mySchedule;

}

@property (nonatomic,retain) NSArray *mySchedule;

@end

Lastly here again is my implementaion file for "Schedule".

#import "Schedule.h"
#import "AnotherViewController.h"


@implementation Schedule

@synthesize mySchedule;

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{

    return mySchedule.count;
}

- (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //create a cell
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault
                                                   reuseIdentifier:@"cell"];
    //fill it with contents
    cell.textLabel.text = [mySchedule objectAtIndex:indexPath.row];
    //return it
    return cell;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherViewController" bundle:nil];
    [self.navigationController pushViewController:anotherViewController animated:YES];
    [anotherViewController release];



}

/*
 // The designated initializer.  Override if you create the controller programmatically and want to perform customization that is not appropriate for viewDidLoad.
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil {
    if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
        // Custom initialization
    }
    return self;
}
*/


// Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- (void)viewDidLoad {
    NSString *myFile = [[NSBundle mainBundle] pathForResource:@"exercise" ofType:@"plist"];
    mySchedule = [[NSArray alloc] initWithContentsOfFile:myFile];

    [super viewDidLoad];
}


/*
// Override to allow orientations other than the default portrait orientation.
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    // Return YES for supported orientations
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}
*/

- (void)didReceiveMemoryWarning {
    // Releases the view if it doesn't have a superview.
    [super didReceiveMemoryWarning];

    // Release any cached data, images, etc that aren't in use.
}

- (void)viewDidUnload {
    // Release any retained subviews of the main view.
    // e.g. self.myOutlet = nil;
}


- (void)dealloc {
    [super dealloc];
}


@end
A: 

Need more code/info. It looks like you implemented tableView:didSelectRowAtIndexPath: and pushed another View Controller onto the stack correctly, so it's hard to say. But here's a hit list:

  • Are you certain tableView:didSelectRowAtIndexPath: is getting called? Did you set a breakpoint? If not, you may have forgotten to set your Schedule class as the delegate either programatically or in Interface Builder.

  • Is schedule's navigation controller definitely set? That is, was it pushed onto a Navigation Controller stack?

  • Are you sure the nib file for AnotherViewController exists?

bpapa
1. I have an NSLog statement that tells me the method is being called. 2. In "schedule" I have declared it as the <UITableViewDelegate, UITableViewDataSource> in my header. Do I need to do this in my rootViewController where I am loading my tabs?3. The nib does exist.
JoshD