Im using Xcode 4.3.2 with storyboards as i'm a newbie so code knowledge is not very good. I have so far created by main view controller which links to my tableview which contains data. However i dont know how to link this to a new view controller, i.e. if i drag a new view controller onto the storyboard page i want to be able to select the cell in the tableview and then opens a new page which contains the details. my code so far with the help of tutorials is:-
Viewcontroller.h
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITabBarDelegate, UITableViewDataSource, UISearchBarDelegate>
{
IBOutlet UITableView * tableView;
IBOutlet UISearchBar * searchBar;
NSArray * allItems;
NSMutableArray * displayItems;
}
@end
Viewcontroller.m
#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
I feel comfortable working out the rest of the app just stuck on this bit and searched tutorials looked at various code but because my knowledge is very limited I just need a dummies guide or better still if someone can tell me what code to add that will be great.
Thanks Guys and help would be appreciated.