Hi guys
Just joined today and looking for some expertise
I have the following code which works ok but i need to push the selection into another page. Ie. when someone clicks on the cell say "K12" from the list i want it to display a page containing information relating to K12. I am very new at programming and is a mine field to say the least but I'm trying to learn in stages so please give me simple responses guys.
The code i have so far in viewcontroller.m is:
any help would be very much appreciated..
Just joined today and looking for some expertise
I have the following code which works ok but i need to push the selection into another page. Ie. when someone clicks on the cell say "K12" from the list i want it to display a page containing information relating to K12. I am very new at programming and is a mine field to say the least but I'm trying to learn in stages so please give me simple responses guys.
The code i have so far in viewcontroller.m is:
Code:
#import "ViewController.h"
@interface ViewController ()
@end
@implementation ViewController
- (void)viewDidLoad
{
[super viewDidLoad];
allItems = [[NSArray alloc] initWithObjects:@"K12", @"K14", @"K16", @"K18", @"K42", @"K43", @"K46", @"K53", @"K60", @"K68", @"K81", @"K83", nil];
displayItems = [[NSMutableArray alloc] initWithArray:allItems];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [displayItems count];
}
- (UITableViewCell *)tableView:(UITableView *)atableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.textLabel.text = [displayItems objectAtIndex:indexPath.row];
return cell;
}
- (void)searchBar:(UISearchBar *)searchBar textDidChange:(NSString *)searchText {
if ([searchText length] == 0) {
[displayItems removeAllObjects];
[displayItems addObjectsFromArray:allItems];
} else {
//here
[displayItems removeAllObjects];
for (NSString * string in allItems) {
NSRange r = [string rangeOfString:searchText options:NSCaseInsensitiveSearch];
if (r.location != NSNotFound) {
[displayItems addObject:string];
}
}
}
[tableView reloadData];
}
- (void)searchBarSearchButtonClicked:(UISearchBar *)aSearchBar {
[searchBar resignFirstResponder];
}
- (void)viewDidUnload
{
[super viewDidUnload];
// Release any retained subviews of the main view.
}
- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
return (interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown);
}
@end
any help would be very much appreciated..