-1

UITableViewController があります。テーブル セルの後に、UITextField が埋め込まれたセルを表示する必要があります。基本的に、代わりに tableView データソースを表示する必要があります。これについて私を助けてください..ありがとう。

編集 #1:NSMutableArray *tableData;次の要素を持つテーブルのデータソースを想像してください。

  • @"Apple"
  • @"Mango"
  • @"Watermelon"

UITableView を次のように表示したい:

  • 1 番目のセル: リンゴ
  • 2 番目のセル:数量を入力するテキスト フィールド
  • 3番目のセル: マンゴー
  • 4 番目のセル:数量を入力するテキスト フィールド
  • 5番目のセル: スイカ
  • 6 番目のセル:数量を入力するテキスト フィールド
  • 7番目のセル:保存ボタン
4

1 に答える 1

1

次のように dataSource メソッドを使用します。

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
  // Return the number of rows in the section.
  return ([m_tableData count]*2)+1;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
   if(indexPath.row == [m_tableData count]*2)
   {
      //cell with button
   }
   else
   {
    if(indexPath.row == 0 || indexPath.row%2 == 0)
    {
      //cell with label for displaying values
    }
    else
    {
      //Load a cell that has an embedded UITextField
    }
   }
}
于 2012-09-04T11:01:50.050 に答える