Wednesday, 18 September 2013

Navigate from tableViewcell to new tableview to new view, Xcode

Navigate from tableViewcell to new tableview to new view, Xcode

I am working with a Xcode project where I have two tableviews and one
ordinary view. The first tableview have 9 different cells and when you
click one of theese I want to navigate to the second tableview and fill it
with contents from a different array depending on which cell you clicked
on in the first tableview.
After that I want to be able to click on a cell in the second tableview
and from there navigate to a view controller that shows different pictures
and text in textfields depending on which cell i clicked there.
I don't know if I'm gonna use prepare for segue or something else.
I am stuck and in a hurry so I would be very grateful for help.
This is the code I have for the first tableView:
#import "ValjKategoriViewController.h"
#import "ValjKupongViewController.h"
#import "Kupong.h"
@interface ValjKategoriViewController ()
@end
@implementation ValjKategoriViewController
@synthesize kategoriArray;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle
*)nibBundleOrNil
{
self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
if (self) {
// Custom initialization
}
return self;
}
- (void)viewDidLoad
{
[super viewDidLoad];
// Do any additional setup after loading the view.
NSArray *array = [[NSArray alloc] initWithObjects:@"Alla aktuella
kuponger",@"Restauranger & Cafeer",@"Dagens lunch",@"Friskvård &
Hälsa", @"Dagligvaror", @"Frisörer",@"Shopping",@"Bil &
Motor",@"Upplevelser & Nöje",nil];
self.kategoriArray = array;
self.title = @"Kategori";
}
- (void)didReceiveMemoryWarning
{
[super didReceiveMemoryWarning];
// Dispose of any resources that can be recreated.
}
- (NSInteger)tableView:(UITableView *)tableView
numberOfRowsInSection:(NSInteger)section
{
return [kategoriArray count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:@"SimpleTableIdentifier"];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleSubtitle
reuseIdentifier:@"SimpleTableIdentifier"];
}
cell.textLabel.text = [kategoriArray objectAtIndex:indexPath.row];
return cell;
}
- (void)tableView:(UITableView *)tableView
didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}

No comments:

Post a Comment