【发布时间】:2012-12-13 13:16:01
【问题描述】:
我创建了一个包含标签的自定义单元格,但是当我在我的表格视图中添加它而不显示时,我的视图控制器不是TableViewController 我已经使用 IB 设置了表格视图并正确设置了它的委托和数据源.
我是这样做的:
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
// Return the number of sections.
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section
{
ExampleAppDataObject* theDataObject = [self theAppDataObject];
return theDataObject.myAudio.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
ExampleAppDataObject* theDataObject = [self theAppDataObject];
NSString *destinationPath = [theDataObject.myAudio objectAtIndex:indexPath.row];
NSArray *parts = [destinationPath componentsSeparatedByString:@"/"];
NSString *filename = [parts lastObject];
AudioInfoCell *cell = (AudioInfoCell*)[tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[AudioInfoCell alloc] initWithFrame:CGRectZero reuseIdentifier:CellIdentifier];
}
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
cell.audioName.text = filename;
return cell;
}
【问题讨论】:
-
您的 numberOfSectionsInTableView: 和 tableView:numberOfRowsInSection: 方法是否返回正确的数字?
-
用代码tableView:numberOfRowsInSection发布方法
-
检查您的 Ary 中是否有一些您在 tableView 中操作的数据
-
伙计们,它显示单元格但不显示我的自定义单元格
标签: iphone ios custom-cell