Ios UITableView使用XIB在目标中的pushview控制器后删除多选项
我是iOS新手,我面临着在表视图上进行多次选择的问题 当我使用pushview控制器选择值时,获取取消选择Ios UITableView使用XIB在目标中的pushview控制器后删除多选项,ios,objective-c,uitableview,Ios,Objective C,Uitableview,我是iOS新手,我面临着在表视图上进行多次选择的问题 当我使用pushview控制器选择值时,获取取消选择 我正在使用这样的代码 - (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath { static NSString *CellIdentifier = @"Cell"; UITableViewCell *cell = [tableVi
我正在使用这样的代码
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *CellIdentifier = @"Cell";
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:CellIdentifier];
if (cell == nil) {
cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:CellIdentifier];
}
cell.textLabel.text=[NSString stringWithFormat:@"%@",[reportshortActivityarray objectAtIndex:indexPath.row]];
if([Selectedarray containsObject:[reportshortActivityarray objectAtIndex:indexPath.row]])
{
[cell setAccessoryType:UITableViewCellAccessoryCheckmark];
}
else
{
[cell setAccessoryType:UITableViewCellAccessoryNone];
}
return cell;
}
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if(![Selectedarray containsObject:[reportshortActivityarray objectAtIndex:indexPath.row]]){
[Selectedarray addObject:[reportshortActivityarray objectAtIndex:indexPath.row]];
txtactivity.text = [Selectedarray componentsJoinedByString:@","];
DefaultActivityString=txtactivity.text;
}
NSLog(@"Selected Value =%@",txtactivity.text);
if(![SelectedIDarray containsObject:[reportidActivityarray objectAtIndex:indexPath.row]]){
[SelectedIDarray addObject:[reportidActivityarray objectAtIndex:indexPath.row]];
lblactivity.text = [SelectedIDarray componentsJoinedByString:@","];
}
NSLog(@"Selected Value =%@",lblactivity.text);
[[activitytable cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryCheckmark];
activitytable.hidden=NO;
}
- (void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
if([Selectedarray containsObject:[reportshortActivityarray objectAtIndex:indexPath.row]]){
[Selectedarray removeObject:[reportshortActivityarray objectAtIndex:indexPath.row]];
txtactivity.text = [Selectedarray componentsJoinedByString:@","];
}
if([SelectedIDarray containsObject:[reportidActivityarray objectAtIndex:indexPath.row]]){
[SelectedIDarray removeObject:[reportidActivityarray objectAtIndex:indexPath.row]];
lblactivity.text = [SelectedIDarray componentsJoinedByString:@","];
}
NSLog(@"Selected Value =%@",lblactivity.text);
[[activitytable cellForRowAtIndexPath:indexPath] setAccessoryType:UITableViewCellAccessoryNone];
activitytable.hidden=NO;
}
多选
和on按钮
-(IBAction)btnaddClick:(id)sender
{
IncidentHSQE *inc=[[IncidentHSQE alloc] initWithNibName:@"IncidentHSQE" bundle:nil];
[self.navigationController pushViewController:inc animated:YES];
}
选定的数据将被删除。
如何恢复所选数据。
提前谢谢 你的问题我不清楚。从推送的viewcontroller返回当前的viewcontroller时,将取消选择tableview行。是吗?@Dipankar Das-是的。它们被取消选择。