我有奇怪的问题;有谁知道为什么下面的表视图不加载我的自定义单元格?是的,数据源和委托连接到视图控制器:)我以前做过这个,但突然之间它就像缺少一些东西。自定义单元格不在tableview中加载?
.H
@interface MyAccountViewController : UIViewController {
IBOutlet UITableView *StorageTableView;
NSArray *StoredItems;
NSMutableData *data;
}
.M
- (int)numberOfSectionsInTableView: (UITableView *)tableview
{
return 1;
}
- (int)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
return [StoredItems count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *DoctorsTableIdentifier = @"StorageItemTableViewCell";
StorageItemTableViewCell *cell = (StorageItemTableViewCell *)[tableView dequeueReusableCellWithIdentifier:DoctorsTableIdentifier];
if (cell == nil)
{
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"StorageItemTableViewCell" owner:self options:nil];
cell = [nib objectAtIndex:0];
NSDictionary *node = [StoredItems objectAtIndex:indexPath.row];
[[cell itemName] setText:[node objectForKey:@"title"]];
[[cell itemDescrip] setText:[[[[node objectForKey:@"body"] objectAtIndex:0] objectForKey:@"raw"] objectForKey:@"value"]];
}
return cell;
}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
return 99;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
}
你做了什么故障?数据源方法是否被调用? [StoredItems计数]返回的是什么? – rdelmar