nikey
nikey

Reputation: 81

popOver table view

In my project , On clicking the button the string present in the button Action method should store in popover table view cell.

I cam able to store a single sting , to the first cell ....

And now my problem is i had Four buttons each button action consists of 4 strings , and now the should at a time to the popover table view ,,,

  #import "SecondDetailViewController.h"
  -(IBAction)viewButtonPressed:(id)sender
  {
     [super viewDidUnload];

     //create the view controller from nib
     self.tablePopoverController = [[[TablePopoverController alloc] 
                             initWithNibName:@"TablePopover" 
                             bundle:[NSBundle mainBundle]] autorelease];

      ////-------------------------------


     myArray = [[NSMutableArray alloc]     initinitWithObjects:myString,myString2,myString3,myString4,myString5,myString6,nil];

     tablePopoverController.getingOrder = myArray ; 

      NSLog(@"table popo  %@",myArray);

      tablePopoverController.contentSizeForViewInPopover = CGSizeMake(250, 250);

      //create a popover controller
      self.popoverController = [[[UIPopoverController alloc]
                                 initWithContentViewController:tablePopoverController] autorelease];


      //present the popover view non-modal with a
      //refrence to the button pressed within the current view
      [popoverController presentPopoverFromBarButtonItem:sender permittedArrowDirections:UIPopoverArrowDirectionAny animated:YES];

  }

  -(IBAction)orderButtonPressed
  {
      myString = staterlable1.text;
      [myArray addObject:myString];
      NSLog(@"myArray%@",myString);
  }

  -(IBAction)orderButton2Pressed
  {
      myString2 = staterlable2.text;
      NSLog(@"myArray%@",myString2);
      [myArray addObject:myString2];
  }
  -(IBAction)orderButton3Pressed
  {
      myString3 = staterlable3.text;
      [myArray addObject:myString3];
      NSLog(@"myArray%@",myString3);
  }

  -(IBAction)orderButton4Pressed
  {
      myString4 = staterlable4.text;
      [myArray addObject:myString4];
      NSLog(@"myArray%@",myString4);
  }

  -(IBAction)orderButton5Pressed
  {
      myString5 = staterlable5.text;
      [myArray addObject:myString5];
      NSLog(@"myArray%@",myString5);

  }
  -(IBAction)orderButton6Pressed
  {
      myString6 = staterlable6.text;
      [myArray addObject:myString6];
      NSLog(@"myArray%@",myString6);

my Problem Is after clicking these buttons the myString1 - to - myString6 NSString objects Should Store into NSMutableArray so That i will display all the strings in the TableViewPopOverController which will popover when clicking the another button in the second detailViewController........

thanks in Advance......

Upvotes: 2

Views: 4323

Answers (1)

fsaint
fsaint

Reputation: 8759

The usual way to do this is to embed TablePopoverController in a UINavigationController. Then, in TablePopoverController when handling tableView:tableView didSelectRowAtIndexPath:indexPath push detailViewController into the UINavigationController.

For example, you could build Controller structure the following way (based on your example):

  //create a popover controller
  self.popoverController = [[[UIPopoverController alloc]  initWithContentViewController:[[[UINavigationController alloc] initWithRootViewController:initWithContentViewController:tablePopoverController] autorelease]] autorelease];

It is similar to your popover-creation code, put inserts a UINavigationController under the popover. Now, in TablePopoverController you should handle row selections the usual way with a UINavigationController

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    DetaiViewController *detail = [[DetaiViewController alloc] init];
    /* Configure detail using indexpath here indexPath
    ...
    */
    [self.navigationController pushViewController:detail animated:YES];
}

This will work as expected (by pushing the new view into the UINavigationController) because we set controller structure with a UINavigationController.

Upvotes: 2

Related Questions