我有一个我试图加载数据的TableView。从NSLog
显示的数据是正确的,并呈现。然而,下面的方法没有被调用,例如在NSLog
注释不会出现在所有:什么触发cellForRowAtIndexPath?
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:CellIdentifier];
// UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
}
NSString *cellValue = [listOfStates objectAtIndex:indexPath.row];
cell.textLabel.text = cellValue;
return cell;
NSLog(@"Passed: cellForRowAtIndexPath");
}
同样在init没有被任何运行。我虽然init始终运行,如果存在?
- (id)init {
if ((self = [super init])) {
listOfStates = [[NSMutableArray alloc] init];
stateName = [[NSString alloc] init];
NSLog(@"INIT StateName %@", stateName);
}
return self;
NSLog(@"Passed: init");
}
任何想法?
非常感谢您的智慧。 initWithFrame或initWithSTyle都没有被激活? 对于数据源,所以我需要把cell.pickerDelegate = self;进入cellForRowAtIndexPath?到目前为止,我总是使用StoryBaord来处理数据源。 并感谢您踢我的退货顺序:-) – 2012-07-14 09:48:01
哪个类的init方法是你重写? pickerDelegate是完全不同的东西,但你确实需要将tableView的dataSource设置为一个对象(如果你使用UITableViewController,这是为你完成的,数据源是控制器) – wattson12 2012-07-14 09:50:18
DataSource和Delegate被链接到TableView中。 – 2012-07-14 11:15:03