在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