我有一個視圖,其中頂部有一個按鈕,底部有一個自定義單元格的tableview
自定義單元格我有一個文本字段,試圖訪問tableview單元格外的文本字段內容對於頂部按鈕上的行方法,只顯示可見單元格的文本,如果滾動到頂部並點擊保存,底部文本字段值爲零,如果我滾動到底部並點擊保存底部的文本字段值是零,我想它有一些事情與標識符出列可重複單元格。訪問cellforrow之外的tableview內容
//實現代碼如下方法
- (UITableViewCell*) tableView:(UITableView*)tableView cellForRowAtIndexPath:(NSIndexPath*)indexPath{
static NSString *simpleTableIdentifier = @"AcessoryCell";
AcessoryCell *cell = (AcessoryCell *)[tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"AcessoryCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
}
}
for (NSInteger i=0; i<selectedButtonsArray.count; i++)
{
NSNumber * num = [selectedButtonsArray objectAtIndex:i];
NSIndexPath * indexPath=[NSIndexPath indexPathForRow:[num intValue] inSection:0];
AcessoryCell *cell = (AcessoryCell *) [self.acessoryTableView cellForRowAtIndexPath:indexPath];
NSLog(@"text field text is %@", cell.celltextField.text);
}
日誌
text is 1
text is 1
text is 1
text is 1
text is 1
text is 1
text is (null)
text is (null)
如果我滾動到底部再登錄是
text is (null)
text is (null)
text is 1
text is 1
text is 1
text is 1
text is 1
text is 1
遺憾的是沒有工作,我得到了同樣的問題。 – 2014-11-03 07:27:07
如果我嘗試訪問單元格通過AcessoryCell * cell =(AcessoryCell *)[tableView dequeueReusableCellWithIdentifier:[self cellIdentifierForIndexPath:indexPath] forIndexPath:indexPath]; 我得到一個錯誤不可見@interface爲「類」聲明選擇器cellIdentifierForIndexPath – 2014-11-03 07:35:10
@SyedIsmailAhamed嘗試刪除靜態關鍵字,檢查編輯的答案 – Kampai 2014-11-03 07:36:33