2012-01-17 65 views
0

我想將單元格添加到UItableView中,就像在ipad上的mail.app中一樣。在我的小區我有UITextFields,我必須改變這種方法將焦點設置將單元格添加到uitableView中像Mail.app

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)newIndexPath{ 
    NSLog(@"%d",newIndexPath.row); 
    UITextField* field = (UITextField *) [tblView viewWithTag: newIndexPath.row]; 

    int l_cellNum = field.tag; 
    if(l_cellNum == 1 && isAddedNewRow == FALSE){ 
     isAddedNewRow = TRUE; 
     [cellsArray insertObject:@"CC" atIndex:1]; 
     [cellsArray insertObject:@"BCC" atIndex:2]; 

     CGRect tvbounds = [tblView bounds]; 
     [tblView setBounds:CGRectMake(tvbounds.origin.x, 
             tvbounds.origin.y, 
             tvbounds.size.width, 
             tvbounds.size.height)]; 
     NSIndexPath *path1 = [NSIndexPath indexPathForRow:1 inSection:0]; 
     NSIndexPath *path2 = [NSIndexPath indexPathForRow:2 inSection:0]; 
     NSArray *indexArray = [NSArray arrayWithObjects:path1,path2,nil]; 
     [tblView insertRowsAtIndexPaths:indexArray withRowAnimation:UITableViewRowAnimationTop]; 
     [tblView reloadRowsAtIndexPaths:[NSArray arrayWithObject:newIndexPath] withRowAnimation:UITableViewRowAnimationFade]; 
    } 
    [field becomeFirstResponder]; 
} 

但是當我點擊到小區之一,我加2個細胞(如mail.app),但我的文本框的標籤不更新,我不能把重點放在它=(如果我打電話reloaddata方法它調用-cellForRowAtIndexPath與這個新細胞在開始和所有細胞之後,它不會工作太多。

回答

1

這聽起來像你什麼我們正在尋找的是一種名爲UITableViewStyleSubtitle的內置單元格,您可以像iPad Mail.app一樣自定義字幕。請看iOS documentation中的這一頁。然後,您可以設置的字幕10到你需要的文字。
此外,iOS文檔有關於customizing table view cells的更多信息。

相關問題