- (IBAction) creatorAction:(id)sender
{
button=(UIButton *)sender;
NSInteger tag = [button tag];
NSLog(@" creator :%ld",(long)tag);
button.selected = !button.selected;
if(button.selected)
{
button.selected = TRUE;
NSLog(@" creator status :%d",button.selected);
NSObject *creatorData = [totalString objectAtIndex:tag];
NSLog(@"creator data added: %@",creatorData);
Creator[tag][email protected]"True";
if((Creator[tag][email protected]"True"))
{
Modifier[tag][email protected]"True";
[modifierButton setHidden:YES];
Approver[tag][email protected]"True";
[approverButton setHidden:YES];
}
[cs addObject:creatorData];
}
else
{
button.selected = FALSE;
Creator[tag][email protected]"False";
if((Creator[tag][email protected]"False"))
{
Modifier[tag][email protected]"False";
[modifierButton setHidden:NO];
Approver[tag][email protected]"False";
[approverButton setHidden:NO];
}
NSLog(@" creator status :%d",button.selected);
NSObject *creatorData = [totalString objectAtIndex:tag];
NSLog(@"approver data removed: %@",creatorData);
// [createrArray removeObject:creatorArray];
[cs removeObject:creatorData];
}
NSLog(@"Final creater array: %@",Creator);
NSLog(@"Final cs array: %@",cs);
//modifierButton.enabled = NO;
}
- (IBAction) modifierAction:(id)sender
{
button1=(UIButton *)sender;
NSInteger tag = [button1 tag];
NSLog(@" modifier :%ld",(long)tag);
//NSLog(@"%d",AddAdminViewController.selectedId));
button1.selected = !button1.selected;
if(button1.selected)
{
button1.selected = TRUE;
NSLog(@" modifier status :%d",button1.selected);
NSObject *modifierData = [totalString objectAtIndex:tag];
NSLog(@"modifier data added: %@",modifierData);
Modifier[tag][email protected]"True";
// [modifierArray addObject:modifierArray];
[ms addObject:modifierData];
}
else
{
button1.selected = FALSE;
Modifier[tag][email protected]"False";
NSLog(@" modifier status :%d",button1.selected);
NSObject *modifierData = [totalString objectAtIndex:tag];
NSLog(@"approver data removed: %@",modifierData);
// [modifierArray removeObject:modifierArray];
[ms removeObject:modifierData];
}
NSLog(@"Final Modifier array: %@",Modifier);
NSLog(@"Final ms array: %@",ms);
}
- (IBAction) approverAction:(id)sender
{
button2=(UIButton *)sender;
NSInteger tag = [button2 tag];
NSLog(@" approver :%ld",(long)tag);
//NSLog(@"%d",AddAdminViewController.selectedId));
button2.selected = !button2.selected;
if(button2.selected)
{
button2.selected = TRUE;
NSLog(@" approver status :%d",button2.selected);
NSObject *approverData = [totalString objectAtIndex:tag];
NSLog(@"approver data added: %@",approverData);
Approver[tag][email protected]"True";
[as addObject:approverData];
}
else
{
button2.selected = FALSE;
Approver[tag][email protected]"False";
NSLog(@" approver status :%d",button2.selected);
NSObject *approverData = [totalString objectAtIndex:tag];
NSLog(@"approver data removed: %@",approverData);
// [approverArray removeObject:approverData];
[as removeObject:approverData];
}
NSLog(@"Final Approver array: %@",Approver);
NSLog(@"Final as array: %@",as);
}
-(void)tableView:(UITableView *)tableView didDeselectRowAtIndexPath:(NSIndexPath *)indexPath
{
[tableView cellForRowAtIndexPath:indexPath].accessoryType = UITableViewCellAccessoryNone;
}
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
NSLog(@"Hello %lu",(unsigned long)[totalString count]);
return [totalString count];
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
static NSString *simpleTableIdentifier = @"cell";
// NSLog(@"%ld",(long)indexPath.row);
UIImage *image1 = [UIImage imageNamed:@"images.png"];
UIImage *image2 = [UIImage imageNamed:@"Image-1.png"];
UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:simpleTableIdentifier];
if (!cell) {
cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:simpleTableIdentifier];
}
creatorButton = [[UIButton alloc] initWithFrame:CGRectMake(250.0, 20.0, 20.0, 20.0)];
[creatorButton addTarget:self action:@selector(creatorAction:) forControlEvents:UIControlEventTouchUpInside];
[creatorButton setImage:image1 forState:UIControlStateNormal];
[creatorButton setImage:image2 forState:UIControlStateSelected];
creatorButton.tag = indexPath.row;
creatorButton.backgroundColor = [UIColor clearColor];
creatorButton.selected = NO;
[cell addSubview:creatorButton];
button.selected = FALSE;
NSLog(@"creator tag:%ld",(long)creatorButton.tag);
NSLog(@"Index row value %ld",(long)indexPath.row);
modifierButton = [[UIButton alloc] initWithFrame:CGRectMake(310.0, 20.0, 20.0, 20.0)];
[modifierButton addTarget:self action:@selector(modifierAction:) forControlEvents:UIControlEventTouchUpInside];
[modifierButton setImage:image1 forState:UIControlStateNormal];
[modifierButton setImage:image2 forState:UIControlStateSelected];
modifierButton.tag =indexPath.row;
modifierButton.backgroundColor = [UIColor clearColor];
modifierButton.selected = NO;
[cell addSubview:modifierButton];
button1.selected = FALSE;
NSLog(@" Modifier tag :%ld",(long)modifierButton.tag);
approverButton = [[UIButton alloc] initWithFrame:CGRectMake(375.0, 20.0, 20.0, 20.0)];
[approverButton addTarget:self action:@selector(approverAction:) forControlEvents:UIControlEventTouchUpInside];
[approverButton setImage:image1 forState:UIControlStateNormal];
[approverButton setImage:image2 forState:UIControlStateSelected];
approverButton.tag = indexPath.row;
approverButton.backgroundColor = [UIColor clearColor];
approverButton.selected = NO;
[cell addSubview:approverButton];
button2.selected = FALSE;
NSLog(@" Approver tag :%ld",(long)approverButton.tag);
UIImage *profileImages = [UIImage imageNamed:@"image2.png"];
cell.imageView.image = profileImages;
cell.textLabel.text = [totalString objectAtIndex:indexPath.row];
return cell;
}
以上就是如果一個複選框,單擊其他複選框,在同一行應與多個同一行的tableview隱藏代碼tableview中應該隱藏。當我點擊第一個複選框從行隱藏最後一個對象複選框。我在一行中添加了三個按鈕,它們根據行重複相同的操作。應該怎麼做? 如果複選框框中單擊了其他複選框連續使用目標C
什麼問題面臨這裏? – KKRocks
如果我點擊特定行的創建者複選框,那麼剩餘的修飾符和批准者應該隱藏,但在我的情況下,它隱藏最後一行修飾符和批准者而不是第一行。 –
我可以幫助你,但你必須耐心等待。 – user3182143