wag*_*shi 1 uitableview accessoryview ios
我的问题与此类似:
但是我想只为具有细节的单元格显示带有DetailDisclosureButton的accessoryView.
我写了一些代码,但我不知道用哪种方法.
if (totalcount == 0 && totalcount2 == 0)
{
cell.accessoryType = UITableViewCellAccessoryNone;
}
else
{
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
Run Code Online (Sandbox Code Playgroud)
totalcount和totalcount2是两个可变数组的计数,它告诉我单元格是否有详细信息.
如果我的问题不明确,请问我,谢谢.
- (UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString* identifierString;
if(totalCount == 0 && totalCount2 == 0) {
identifierString = @"0";
} else {
identifierString = @"1";
}
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:identifierString];
if(cell == nil) {
cell = [[[UITableViewCell alloc] initWithStyle:YOUR_CELL_STYLE
reuseIdentifier:identifierString] autorelease];
if ([identifierString intValue] == 0) {
cell.accessoryType = UITableViewCellAccessoryNone;
} else {
cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton;
}
//do whatever setup you need to do
}
return cell;
}
Run Code Online (Sandbox Code Playgroud)
虽然对我而言,似乎如果totalCount和totalCount2都等于0,那么所有单元格将具有相同的附件类型.这就是你的意思吗?如果没有,您可能想重新考虑您的逻辑.
| 归档时间: |
|
| 查看次数: |
4077 次 |
| 最近记录: |