2012-03-07 25 views
-2

我很迷惑與文本字段。我在每個表格單元格的表格上添加文本字段,並且當我在其他文本字段上反映的任何文本字段上插入某個值時,但是當我滾動並轉到最後一個文本字段時,如果我在該文本字段中插入了一些文本那麼它不會在文本字段中反映出來。如果有人知道這件事,請告訴我關於文本字段不更改值Iphone

謝謝。

+3

你可以增加你的問題中添加相關的代碼獲得有用的答案的概率。 – dasdom 2012-03-07 11:33:28

+1

我想你不明白tableview的重用邏輯。閱讀關於TableViews和'dequeueReusableTableViewCell'的文檔 – calimarkus 2012-03-07 11:36:06

回答

0

檢查cellForRowAtIndexPath方法中的單元格分配。不正確的分配/或釋放自定義單元格會產生這樣的問題。我之前遇到過它。

你可以嘗試這樣的代碼,

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
static NSString *CellIdentifier = @"Cell"; 

//your custom cell class object 
    customCell *cell= (customCell *)[tableView dequeueReusableCellWithIdentifier:CellIdentifier]; 

    if (cell==nil) 
    { 
      cell=[[[customCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier] autorelease]; 
    } 

    //Here you can add your textfield. You can give tags to individual textfield to access them in future. 
}