0

I am developing app for iPad. I am able to display UIPopoverController with tableView with some list in VIEW1.

I want to navigate from VIEW1 to VIEW2 when user select a row from table.

In other words,

  1. VIEW1 contains a button1.

  2. When user presses button1, then Popover displayed on VIEW1.

  3. In popover, there is a table with some rows. (VIEW1)

  4. When user select a row then it should call VIEW2 i.e navigate from VIEW1 to VIEW2.

Thanks for any help.

Dilip Lilaramani
  • 1,126
  • 13
  • 28

4 Answers4

1

In tableview delegate method didSelectRowAtIndexPath you can call method as follows:

1.While initializing popover controller define target and selector as follows: [theController setTarget:self andSelector:@selector(yourMethod:)];

2.and In view controller which contains tableview, you can define setTarget method as follows:

-(void)setTarget:(id)inTarget andSelector:(SEL)inSelector {
    mTarget = inTarget;
    m_Selector = inSelector;
}

where mTarget is of id type and mSelector is selector.

3.Then didSelectRowAtIndexPath you can call yourMethod as follows:

if ([m_Target respondsToSelector:m_Selector]) {
        [m_Target performSelector:m_Selector withObject:nil];
    }

And if table view is in same view then you can call yourMethod in didSelectRowAtIndexPath.

Nuzhat Zari
  • 3,398
  • 2
  • 24
  • 36
0

In the table views controller file you'll want to use the didSelectRowAtIndexPath method to present view2, e.g:

[self presentViewController:view2controller animated:YES completion:nil];
Mick MacCallum
  • 129,200
  • 40
  • 280
  • 281
0

I found the answer. Just add UITableViewController to UIPopOverController to navigate from VIEW1 to VIEW2.

Thanks for your efforts. Below is the code.

        tableViewController = [[UITableViewController alloc]initWithStyle:UITableViewStylePlain];
        tableViewController.tableView = tblView;
        tableViewController.tableView.delegate = self;
        tableViewController.tableView.dataSource = self;
        UIPopoverController *popover = [[UIPopoverController alloc] initWithContentViewController:tableViewController];
        self.popoverController = popover;
        popoverController.delegate = self;

        [popoverController setPopoverContentSize:CGSizeMake(442.0f, 527.0f)];
        [popoverController presentPopoverFromRect:CGRectMake(bkBtn.frame.origin.x+bkBtn.frame.size.width/2, bkBtn.frame.origin.y, 442.0f, 527.0f) inView:self.view permittedArrowDirections:UIPopoverArrowDirectionDown animated:YES];

        [tableViewController.tableView reloadData];
Dilip Lilaramani
  • 1,126
  • 13
  • 28
0
 - (UITableViewCell *)tableView:(UITableView *)tableView 
         cellForRowAtIndexPath:(NSIndexPath *)indexPath {
VIEW2 *view2=[[VIEW2 alloc]initWithName:@"VIEW2" bundle:[NSBundle mainBundle]];
[self.navigationController pushViewController:view2 animated:YES];
[view2 release];
}
just try it.This will help you.