【发布时间】:2010-12-17 13:40:48
【问题描述】:
我对设置表格视图单元配件有点困惑。
我在我的表格中修复了两个部分
- 首页
- 办公室
我想要的是如下......
- 当用户点击任何单元格时
- 单元格被选中 &
- 我想设置为已选中(设置 uitableviewcell 附件类型 - 已选中单元格)
- 现在所有其他单元格的附件类型也应设置为
- 适用的视图单元配件类型无
我尝试了以下代码。但我发现 indexpath.row & indexpath.section 是只读属性。
// Override to support row selection in the table view.
-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath {
[tblProfileView deselectRowAtIndexPath:indexPath animated:YES];
int i,max;
UITableViewCell *x; NSIndexPath *tt;
for(i=0;i<[tblProfileView numberOfRowsInSection:0];i++)
{
tt.row=i; tt.section=0;
x=[tblProfileView cellForRowAtIndexPath:];
[x setAccessoryType:UITableViewCellAccessoryNone];
}
for(i=0;i<[tblProfileView numberOfRowsInSection:1];i++)
{
tt.row=i; tt.section=1;
x=[tblProfileView cellForRowAtIndexPath:tt];
[x setAccessoryType:UITableViewCellAccessoryNone];
}
x=[tblProfileView cellForRowAtIndexPath:indexPath];
[x setAccessoryType:UITableViewCellAccessoryCheckmark];
// Navigation logic may go here -- for example, create and push another view controller.
// AnotherViewController *anotherViewController = [[AnotherViewController alloc] initWithNibName:@"AnotherView" bundle:nil];
// [self.navigationController pushViewController:anotherViewController animated:YES];
// [anotherViewController release];
}
【问题讨论】:
-
在这里查看我对此的回答:stackoverflow.com/a/57915835/8684510
标签: iphone objective-c xcode uitableview