popOver表视图 [英] popOver table view

查看:70
本文介绍了popOver表视图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我的项目中,单击按钮后,按钮Action方法中存在的字符串应存储在弹出表视图单元格中.

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 ....

现在我的问题是我有四个按钮,每个按钮动作由4个字符串组成,现在一次应出现在弹出表视图中,

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);

我的问题是单击这些按钮后,myString1到myString6 NSString对象应该存储到NSMutableArray中,这样我将在TableViewPopOverController中显示所有字符串,当单击第二个detailViewController中的另一个按钮时,该字符串会弹出. ...

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........

预先感谢...

推荐答案

通常的方法是将TablePopoverController嵌入UINavigationController中.然后,在TablePopoverController中处理tableView:tableView didSelectRowAtIndexPath:indexPath时,将detailViewController推入UINavigationController中.

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.

例如,您可以通过以下方式(根据您的示例)构建Controller结构:

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];

类似于您的popover创建代码,请在popover下插入一个UINavigationController.现在,在TablePopoverController中,您应该使用UINavigationController以常规方式处理行选择

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];
}

这将按预期方式工作(通过将新视图推送到UINavigationController中),因为我们使用UINavigationController设置了控制器结构.

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

这篇关于popOver表视图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆