uitableview cell.i에있는 확인란의 형태로 버튼을 사용하는 응용 프로그램을 만들고 있습니다. 해당 확인란의 이미지를 변경하고 상태를 선택 취소하고 있습니다. 이제 내가 다른 단추를 클릭하면 표보기의 모든 셀이 선택되고 셀의 모든 체크 상자의 이미지가 변경됩니다. 방법은 아래 할 수있는 것은 내 샘플 코드버튼 클릭시 모든 uitableview 셀을 선택하는 방법
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
return self.lblArray.count;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
static NSString *tableviewidentifier = @"cell";
TablecellTableViewCell *cell= [self.tblvie dequeueReusableCellWithIdentifier:tableviewidentifier];
if(cell==nil)
{
cell = [[TablecellTableViewCell alloc] initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:tableviewidentifier];
}
cell.lblImage.layer.cornerRadius=3.0f;
cell.lblImage.layer.borderWidth=1.0f;
cell.backgroundColor=[UIColor colorWithRed:(245/255.0) green:(245/255.0) blue:(245/255.0) alpha:1];
if ([self.checkimageArray containsObject:[self.lblArray objectAtIndex:indexPath.row]])
{
[cell.buttonCheckbox setImage:[UIImage imageNamed:@"check_box_ok.png"]
forState:UIControlStateNormal];
}
else
{
[cell.buttonCheckbox setImage:[UIImage imageNamed:@"uncheck.png"]
forState:UIControlStateNormal];
}
cell.buttonCheckbox.tag=indexPath.row;
[cell.buttonCheckbox addTarget:self action:@selector(checkButton:) forControlEvents:UIControlEventTouchUpInside];
cell.lblText.text=[self.lblArray objectAtIndex:indexPath.row];
return cell;
}
-(IBAction)checkButton:(UIButton *)sender
{
CGPoint buttonPosition = [sender convertPoint:CGPointZero toView:self.tblvie];
NSIndexPath *indexPath = [self.tblvie indexPathForRowAtPoint:buttonPosition];
if ([self.checkimageArray containsObject:[self.lblArray objectAtIndex:indexPath.row]]) {
[self.checkimageArray removeObject:[self.lblArray objectAtIndex:indexPath.row]];
[email protected]"";
}
else {
[self.checkimageArray addObject:[self.lblArray objectAtIndex:indexPath.row]];
self.titleLabel.text=[self.lblArray objectAtIndex:sender.tag];
}
[self.tblvie reloadRowsAtIndexPaths:[NSArray arrayWithObject:indexPath] withRowAnimation: UITableViewRowAnimationFade];
}
이며, 여기에 내가 다음을 클릭있는 tableview의 모든 셀을 선택하고 모든 셀의 이미지가 변경되는 내 버튼이지만
- (IBAction)selectbtns:(id)sender {
static NSString *tableviewidentifier = @"cell";
TablecellTableViewCell *cell= [self.tblvie dequeueReusableCellWithIdentifier:tableviewidentifier];
[cell.buttonCheckbox setImage:[UIImage imageNamed:@"check_box_ok.png"]
forState:UIControlStateNormal];
}
작동하지 않습니다
RU이 ** [cell.buttonCheckbox의 setImage 후 시도 : [있는 UIImage imageNamed : @ "check_box_ok.png" ] forState : UIControlStateNormal]; ** line add [yourtableview reloaddata] –
예, ""com.xxx.whyq라는 식별자가있는 번들의 참조 된 이미지를로드 할 수 없습니다.checkboxwithTableview " " –
다시 한 번 다시 실행하십시오. –