在StoryBoard中我有一個場景包含一些TextFields,按鈕和一個UITableView。在UITableView的實例是在頭文件中聲明,但是當我試圖訪問該方法「的cellForRowAtIndexPath」我收到以下錯誤該類不是關鍵值編碼兼容的關鍵tableView
this class is not key value coding-compliant for the key tableView.
我GOOGLE了這個錯誤,有的結果表明,它是關於鏈接DataSource和委託屬性的ViewController,但我仍然收到相同的錯誤
請讓我知道如何解決這個錯誤。
代碼-1:
-(UITableViewCell *) tableView:(UITableView *)tableView
cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
NSLog(@"cellForRowAtIndexPath");
NSString *cellIdentifier = @"cellId";
UITableViewCell *cell = [tableView1
dequeueReusableCellWithIdentifier:cellIdentifier
forIndexPath:indexPath];
if (cell == nil) {
cell = [[UITableViewCell alloc]
initWithStyle:UITableViewCellStyleDefault
reuseIdentifier:cellIdentifier];
}
//[cell.textLabel setText: [dataArray
objectAtIndex:indexPath.row]];
if (textFieldRowNameAsString != nil)
cell.textLabel.text = textFieldRowNameAsString;
return cell;
}
代碼-2:
#import <UIKit/UIKit.h>
@interface ViewController : UIViewController <UITableViewDelegate,
UITableViewDataSource>
{
NSString *textFieldRowNameAsString;
UITableView *tableView1;
UITableViewCell *prototypeCell;
UIView *contentView;
}
圖像-1:
你想「訪問方法'cellForRowAtIndexPath'」的原因是什麼?這通常不是你通常需要做的。 – fishinear