我完全不确定为什么我的附件视图不起作用。我只是想让一些文本出现在 UITableViewCell 的右侧(以及左侧),但只显示左侧的文本。
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
UITableViewCell* cell = [tableView dequeueReusableCellWithIdentifier:@"SwitchCell"];
if (cell==nil){
cell = [[[UITableViewCell alloc] initWithFrame:CGRectZero reuseIdentifier:@"SwitchCell"] autorelease];
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(5, 0, 60, 30)];
cell.textLabel.text = @"left text";
label.text = @"right text";
cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
cell.accessoryView = label;
[label release];
}
return cell;
}
有任何想法吗?谢谢。