我完全不确定为什么我的配件视图不起作用.我只想在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,60,30)]; cell.textLabel.text = @"left text"; label.text = @"right text"; cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator; cell.accessoryView = label; [label release]; } return cell; }
有任何想法吗?谢谢.
解决方法
cell.accessoryView = label;
您将accessoryView设置为标签,因此您不会看到任何披露指示.如果你想要你的单元格中的标题和详细文本,那么使用UITableViewCellStyleValue2像这样初始化它…
cell = [[[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue2 reuseIdentifier:@"cellType"] autorelease];
…然后像这样设置标题和细节……
cell.textLabel.text = @"Title"; cell.detailTextLabel.text = @"Description";
要了解不同的内置表格样式,请查看以下图像…
您可以调整textLabel和detailTextLabel以适合您的口味.
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。