2012-11-01 62 views

回答

0

這不是按鈕上的文本框。實際上它是表格視圖內的文本框。您必須執行以下操作:

  1. 以nib上的表格視圖進行操作。
  2. 創建出口並設置委託和數據源。
  3. 然後將下面的代碼添加到.m文件中。

嘗試在此之前這個

設置行的表視圖都有數。

- (UITableViewCell *)tableView:(UITableView *)table cellForRowAtIndexPath:(NSIndexPath *)indexPath { 
    UITableViewCell *cell = [table dequeueReusableCellWithIdentifier:@"Cell"]; 
    if(cell == nil) 
     cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"] autorelease]; 

    cell.textLabel.text = [[NSArray arrayWithObjects:@"First",@"Second",@"Third",@"Forth",@"Fifth",@"Sixth",@"Seventh",@"Eighth",@"Nineth",@"Tenth",nil] 
          objectAtIndex:indexPath.row]; 

    if (indexPath.row % 2) { 
     UITextField *textField = [[UITextField alloc] initWithFrame:CGRectMake(0, 0, 200, 21)]; 
     textField.placeholder = @"Enter Text"; 
     textField.text = [inputTexts objectAtIndex:indexPath.row/2]; 
     textField.tag = indexPath.row/2; 
     textField.delegate = self; 
     cell.accessoryView = textField; 
     [textField release]; 
    } else 
     cell.accessoryView = nil; 

    cell.selectionStyle = UITableViewCellSelectionStyleNone; 
    return cell;   
} 

或者,你可以看到這個鏈接See this answer on SO

0

這是一個基本的分組UITableView。閱讀Apple文檔。這方面也有很多教程。

+0

這應該是一個評論 – NAZIK