wOlVeRiNe
wOlVeRiNe

Reputation: 575

how to Navigate from one cell to next view?

I want my app to have 5 rows and each row has a particular height. Each row has a title, subtitle and an image. Then i want to be able to navigate to the next page when i tap on either of the rows(for e.g say 3rd row). how do i do this?

Upvotes: 1

Views: 1741

Answers (4)

user523234
user523234

Reputation: 14834

Answer to your 2nd part of the question is the initWithStyle:UITableViewCellStyleSubtitle…. this one allows you to have a title and subtitle. For the image, each cell has already built-in.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
        if (cell == nil) 
    {
        cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier] autorelease];
        cell.accessoryType = UITableViewCellAccessoryNone;
    }
    NSString *title = (@"your title");
    NSString *subTitle = (@"your subtitle");
    cell.textLabel.text = title;   //title
    cell.detailTextLabel.text = subTitle;   //subtitle
    NSString *filePath = //file path to your image
    UIImage *image = [UIImage imageWithContentsOfFile:filePath];
    cell.imageView.image = [myThumbnailClass image];  //image
}

Upvotes: 1

Warrior
Warrior

Reputation: 39374

Use the tableview delegate method

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

SingleProductViewController is the new view you want to navigate

All the best

Upvotes: 0

EXC_BAD_ACCESS
EXC_BAD_ACCESS

Reputation: 2707

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {

if(indexPath.row==0)
{
 singleProductViewController=[[SingleProductViewController alloc]initWithNibName:@"SingleProductViewController" bundle:nil];
    [self.navigationController pushViewController:singleProductViewController animated:YES];
[singleProductViewController release];
}
else if(indexPath.row==1)
{
//Sec view Navigation
}
//Like wise u go on


} 

Upvotes: 1

beryllium
beryllium

Reputation: 29767

Use method for handle tableview touch

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
}

You can check indexPath which row taped.

See this tutorial - Navigating a Data Hierarchy With Table Views

Upvotes: 0

Related Questions