iCoder
iCoder

Reputation: 1318

Modify tableview (lied on another view controller ) based on table row selected

How to change the Images in table view which is lied in the new view controller based on row selected .

e.g. Say I hv category table in my Category view controller.Now when user taps on Camera,a new view controller should load containing all the camera images and on tap of any image,it should display its Detail.

how to implement this , as I am new to this tech.,Please help me ...

Upvotes: 0

Views: 151

Answers (1)

madLokesh
madLokesh

Reputation: 1878

you can follow some simple steps to make it working.

1. First View: add the following code in your didSelectRowAtIndexPath method of tableview

-(void)tableView:(UITableView *)tableViewdidSelectRowAtIndexPath:(NSIndexPath *)indexPath
  {
    //Fetch the value of the selected row in NSString

    NSString *tableRowValue = cell.textLable.text;


    //Call the next view

    secondView *secondViewController = [[secondVIew alloc] initWithNibName:@"secondView" bundle:nil];

    secondViewController.modalTransitionStyle = UIModalTransitionStyleCrossDissolve ;

    //Initialize the view with the clicked row value thwough NSString variable 
    [secondViewController initializeWith:tableRowValue];

  }

2.Second View:

In your .h file, add the following initialization method:

-(void)initializeWith:(NSString *)sentRowValue;

IN your .m file, implement the initilization method:

-(void)initializeWith:(NSString*)sentRowValue
  {
      NSString *receivedRowValue = sentRowValue;
      //take log to check 
  }


// now perform all the table view delegate methods using the value you have received.

NOTE: declare all the variables in your .h file and make them as property and synthesize them in your .m file

hope this helps

Upvotes: 1

Related Questions