0

In my secnario I have maintaining within mainviewcontroller one page viewcontroller with 10 pages (viwcontrollers) and one tableviw with multiple rows. Now If I swipe the pageviewcontroller (top box) I can get page Index. Same time underthe table row If I select I need to get page view controller Index value.

enter image description here

Sanju
  • 129
  • 1
  • 10

2 Answers2

1

Because not having the enough reputation to comment , i am putting my view in answer. @Sanju you are getting index of PageViewController . you only need to print that index when selecting TableViewCell.

just save that index value somewhere. i suggest to save in NSUserDefaults and you can use your index value anywhere in your project. go through this Link

Priyanta Singh
  • 77
  • 1
  • 12
  • why to use NSUserDefaults when he can get the results by just passing the value?? as he only wants to display it and not save it. – Shravan Jan 19 '16 at 12:19
  • @Shravan his question is not clear. and as i mentioned that because of not having enough reputation i am posting my comment as answer. the far i understand his question,, is that he is getting the value and the only thing is to print. so i just told him the better way. – Priyanta Singh Jan 19 '16 at 12:44
0
  1. First import the pageViewController.h file in ur tableViewController
  2. Create a @property in pageViewController to store the selected row data
  3. then u need to do the following in ur

didSelectRowAtIndexPath:

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

    [self performSegueWithIdentifier:@"pageView" sender:self];
}

Create a prepareforSegueMethod to send the details

-(void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender       {
pageViewController *sendDetails = segue.destinationViewController;

  if ([[segue identifier] isEqualToString:@"viewDetail"])
  {
      NSIndexPath *indexPath = [self.tableView indexPathForSelectedRow];
      NSInteger row = indexPath.row;
      sendDetails.selectedRow = row;
  }    
}

now u can use the selectedRow property to get the value

so whenever u click the cell u will be directed to the next page along with index number...

Shravan
  • 438
  • 3
  • 17
  • NO. My question is page viewontroller sperate under tableview cell If I select to get pageviewcontroller Index value. Thats it. – Sanju Jan 19 '16 at 11:17
  • 1
    @Sharven -- your answer is different is not related to question please verify once and modify your answer once – Anbu.Karthik Jan 19 '16 at 11:23
  • the index path of each cell will be the pageControllerIndex in this case and u can set the starting viewController in pageview as this.... PageContentViewController *startingViewController = [self viewControllerAtIndex:selectedRow]; so whenever u go to next or previous pages using pageControlDelegate methods u can keep a track of it... and send it back to the tableViewController ur problem is solved..... – Shravan Jan 19 '16 at 11:28
  • @Anbu.Karthik His question wasnt clear and this is what he meant when he asked first... – Shravan Jan 19 '16 at 11:34
  • @Shravan -- ya corerct , i also submit answer in partially – Anbu.Karthik Jan 19 '16 at 11:37
  • however instead of using performSegue he can just use the code inside perform segue to send the values and use it for his purpose.....it wil give the desired results... he needs to figure out himself i guess. the above code have enough concepts to do it – Shravan Jan 19 '16 at 11:42