【发布时间】:2017-12-13 07:14:18
【问题描述】:
我是Objective C 的新手。我有 UITableView,因为我必须从上到下选择 tableview 单元格,也没有选择第一个单元格,第二个单元格将不会被选择,用户也无法选择中间单元格。谁能帮我解决这个问题?
我在此处添加了示例图像,如果用户选择了第二个单元格要启用的第一个单元格,并且如果用户选择了第二个单元格,则第三个单元格要启用其余单元格要禁用。
- (void)viewDidLoad {
[super viewDidLoad];
self.colors = [[NSArray alloc] initWithObjects: @"Red", @"Yellow", @"Green",
@"Blue", @"Purpole", nil];
}
- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {
return 1;
}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return [self.colors count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *CellIdentifier = @"cell";
UITableViewCell *cell = [tableView
dequeueReusableCellWithIdentifier:CellIdentifier forIndexPath:indexPath];
cell.textLabel.text = [self.colors objectAtIndex:indexPath.row];
return cell;
}
【问题讨论】:
-
你需要再写你想做什么?画它什么的
-
你最好用真实的场景来解释......
-
感谢您的回复,作为您请求的一部分,我编辑了我的问题
-
@user19 请使用
didSelectRowAtIndexPath方法显示选择或取消选择功能的真实代码更新。
标签: ios objective-c uitableview