2015-02-01 4 views
0

액세서리 유형 정보 표시기가있는 UITableViewCell이 있습니다. 셀의 크기를 조정하면 셀 액세서리가 수평 적으로 중심에 위치합니다. 어떻게해야 내가 중심에 두지 않고 중심에 둘 수 있을까요?상단에 UITableViewCell 액세서리 보관

가능한 경우 스토리 보드에서 작업하는 것을 선호합니다. 가능하지 않은 경우 프로그램 방식으로 듣는 것이 좋습니다.

답변

0

실수로, 실제로는 tableView의 기본 accessoryView에서 어떤 변경도 할 수 없습니다. 셀에 대한 custom accessView를 만들어야합니다. 액세서리 유형을 무시한 후에는 더 이상 액세서리 유형을 무시하십시오.

는 CellForRowAtIndexPath

if(!cell.accessoryView) 
{ 
    UIImage *image = [UIImage imageNamed:@"image.png"]; 

    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom]; 
    CGRect frame = CGRectMake(0.0, 0.0, image.size.width, image.size.height); 
    button.frame = frame; 
    [button setBackgroundImage:image forState:UIControlStateNormal]; 

    //add target if necessary 
    [button addTarget:self action:@selector(checkButtonTapped:event:) forControlEvents:UIControlEventTouchUpInside]; 

    //apply customisations 
    button.backgroundColor = [UIColor clearColor]; 
    cell.accessoryView = button; 
} 
+0

나는 그것을 시도에서이 코드를 시도했지만 작동하지 않았다. 나는 커스텀 셀을 가지고있다. 아마도 그 이유가 있을까? –

+0

내 코드 –

+0

업데이트 된 코드 확인 –

관련 문제