【问题标题】:changing a picker to table view OR having multiple table views on the same view将选择器更改为表视图或在同一视图上有多个表视图
【发布时间】:2010-05-29 03:10:15
【问题描述】:

由于我使用了选择器,我的 iPad 应用程序被拒绝了。选择器用于控制表格视图。 In my view, a picker was displaying a series of items and when one of those items was selected, it used that selection to populate a table with data. (希望这是有道理的)。现在我需要在没有选择器的情况下执行此操作,因此我需要在表视图中表示选择器中的数据。

我的问题是,我如何在同一个视图中有多个 tableViews?

是否像这样为每个 tableview 设置单独的委托方法一样简单?

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView1
{

    return [xxx count];

}

-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView2
{

    return [yyy count];

}

【问题讨论】:

  • 我不认为这可能是原因。苹果在回复邮件中是否告诉了任何内容?通常苹果会指定拒绝的原因。
  • 是的,他们说选择器只能在弹出视图中使用,这不是我正在做的。
  • 什么理由! UIPickerView 的文档中从未指定过。
  • 事后我确实在 iPad 指南中找到了它。它甚至是粗体,大声笑“仅在弹出框内显示选择器或日期和时间选择器。”

标签: iphone uitableview ipad uipickerview


【解决方案1】:

委托方法的名称是固定的。所以你可以

  1. 使用两个不同的委托实例,或者
  2. 标识方法中的表,例如

    -(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
        if (tableView.tag == 114)
          return [xxx count];
        else
          return [yyy count];
    }
    

【讨论】:

  • 我是个菜鸟,你能扩展一下“使用两个不同的委托实例”吗?
  • @Brodie:例如,您创建@interface A@interface B,然后将tableA.dataSource 分配给A 的实例,将tableB.dataSource 分配给B 的实例。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2015-10-23
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2018-07-14
相关资源
最近更新 更多