Tableview not drilling down
Posted
by JoshD
on Stack Overflow
See other posts from Stack Overflow
or by JoshD
Published on 2010-03-08T16:47:08Z
Indexed on
2010/03/08
16:51 UTC
Read the original article
Hit count: 210
I have a Tableview which is loaded with a dummy list of exercises. I need to drill to a different page. My didSelectRow is being called, but not implementing the method. The app is a tab bar navigation app that loads a UITableView.
#import <UIKit/UIKit.h>
@interface Schedule : UIViewController
<UITableViewDelegate, UITableViewDataSource> {
NSArray *mySchedule;
}
@end
#import "Schedule.h"
#import "AnotherViewController.h"
@implementation Schedule
- (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];
}
© Stack Overflow or respective owner