0
나는 잘 작동하고있는 tableView with custom cell
을 가지고 있지만 버튼을 선택하면 다른 이미지와 다른 현명한 간단한 박스 이미지가 표시됩니다.아이폰에서 선택된 셀에 셀렉트 화살표 이미지를 표시하는 방법
문제가 :
// 가져 : 내가 셀을 선택하면 그것은 또한 다른 셀을하는 주문형 세포 버튼 이미지 selected.Here 내 코드는 것을 보여줍니다
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
if (tableView == employeeTableView)
{
employeeCell = (EmployeeCell *)[employeeTableViewdequeueReusableCellWithIdentifier:@"cell"];
if (!employeeCell)
{
employeeCell = [[EmployeeCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"cell"];
NSArray *nib = [[NSBundle mainBundle] loadNibNamed:@"EmployeeCell" owner:self options:nil];
employeeCell = (EmployeeCell *)[nib objectAtIndex:0];
}
employeeTableView.backgroundColor=[UIColor clearColor];
employeeTableView.backgroundView=nil;
employeeCell.emplyeeName.font=[UIFont fontWithName:@"Arial" size:13];
employeeCell.employeeDepartement.font=[UIFont fontWithName:@"Arial" size:13];
employeeCell.EmployeePosition.font=[UIFont fontWithName:@"Arial" size:13];
Coffee *coffeeObj=[appDelegate.employeeArray objectAtIndex:indexPath.row];
employeeCell.employeeDepartement.textColor = [UIColor brownColor];
employeeCell.EmployeePosition.textColor = [UIColor brownColor];
employeeCell.emplyeeName.textColor = [UIColor brownColor];
employeeCell.emplyeeName.text = coffeeObj.employeeName;
employeeCell.EmployeePosition.text = coffeeObj.employeeJob;
employeeCell.employeeDepartement.text = coffeeObj.departmentName;
if ([employeeCell.selectionButton isSelected])
{
employeeCell.selectedImage.image =[UIImage imageNamed:@"CheckArrow"];
}
else
{
employeeCell.selectedImage.image = [UIImage imageNamed:@"boxbutton"];
}
[employeeCell.selectionButton addTarget:self action:@selector(setSelectCell:) forControlEvents:UIControlEventTouchUpInside];
[employeeCell.selectionButton setTag:indexPath.row];
return employeeCell;
}
if (tableView == trainerTableView)
{
UITableViewCell *cell = [trainerTableView dequeueReusableCellWithIdentifier:@"Cell"];
if (!cell) {
cell =[[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"Cell"];
}
cell.textLabel.text = @"Calvin Banks";
// [appDelegate.trainerArray objectAtIndex:indexPath.row];
return cell;
}
return 0;
}
-(void)setSelectCell:(id)Sender
{
CGPoint point =[Sender convertPoint:CGPointZero toView:employeeTableView];
NSIndexPath *indexPath =[employeeTableView indexPathForRowAtPoint:point];
NSLog(@"indexPath %@",indexPath);
Coffee *cofee;
cofee = [appDelegate.employeeArray objectAtIndex:[Sender tag]];
employeeCell =(EmployeeCell *)[employeeTableView cellForRowAtIndexPath:indexPath];
if ([employeeCell.selectionButton isSelected]) {
[employeeCell.selectionButton setSelected:NO];
employeeCell.selectedImage.image =[UIImage imageNamed:@"boxbutton"];
}
else
{
[employeeCell.selectionButton setSelected:YES];
employeeCell.selectedImage.image =[UIImage imageNamed:@"CheckArrow"];
[selectedEmployees addObject:cofee];
}
}
나는이 내가이 다음 또한 작동 정의 셀 –
사용자 정의 셀을 준 액세서리 유형을위한 요구 하진 않았어. –
@AijazAli 내 편집 answer.it가 작동하는지 확인 하시겠습니까? –