2012-07-24 3 views
0

iPad의 테이블보기 셀에있는 버튼에 이상한 문제가 있습니다.셀의 버튼이 iPad에서 응답하지 않습니다.

는 여기에 더 나은 이해를위한 두 개의 스크린 샷입니다 (버튼이 오른쪽에 흰색 배경 색상을 가지고) :

iPhone

iPad

아이폰에 아무 문제지만,에 iPad이 단추가 응답하지 않습니다. 위치가 올바르게 표시된 것처럼 올바르게 배치 된 것 같습니다.

가있는 UITableViewCell 내 사용자의 코드입니다 :

rightButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
[rightButton setContentMode:UIViewContentModeCenter]; 
[rightButton setBackgroundColor:[UIColor whiteColor]]; 
int xPos = buttonWidth-rightButton.frame.size.width; 
[rightButton setFrame:CGRectMake(xPos, 0, buttonHeight, buttonHeight)]; 
[self.contentView addSubview:rightButton]; 

//buttonWidth = 310, buttonHeight = 60 

이미지와 대상 다른 클래스에 의해 설정됩니다

[cell.rightButton setImage:[UIImage imageNamed:@"options.png"] forState:UIControlStateNormal]; 
[cell.rightButton addTarget:self action:@selector(showOptions:) forControlEvents:UIControlEventTouchUpInside]; 

가 나는 또한 셀에 모든 요소를 ​​배치 한 후이 시도

[self.contentView bringSubviewToFront: rightButton]; 

버튼이 최상위인지 확인하십시오.

작동하지 않았습니다.

이것에 대한 아이디어가 있습니까?


여전히 해결책을 찾지 못했습니다.

나는 그 동안 무슨 짓을 :

  • 다른 모든 셀

다른 아이디어를 객체에

  • 사용하지 않는 사용자 상호 작용 (불필요한 중복을 표시) 셀에 배치 모든 객체를 시각화 ?

  • +0

    'UIButton'을'UITableViewCell'에 추가 한 방법과'UIButton'에 대한 동작을 어떻게 설정하는지 코드를 보여주십시오. – holex

    +0

    자세한 내용을 제공하거나 단추 작성 코드를 작성할 수 있습니까? – Nilesh

    +0

    내 게시물을 코드로 업데이트했습니다. –

    답변

    0

    먼저이 시도 :

    rightButton = [UIButton buttonWithType:UIButtonTypeCustom]; 
    [rightButton setContentMode:UIViewContentModeCenter]; 
    [rightButton setBackgroundColor:[UIColor whiteColor]]; 
    int xPos = buttonWidth-rightButton.frame.size.width; 
    [rightButton setFrame:CGRectMake(xPos, 0, buttonHeight, buttonHeight)]; 
    [self.contentView addSubview:rightButton]; 
    [self.contentView bringSubviewToFront: rightButton] 
    [self.contentView bringSubviewToFront: rightButton]; 
    rightButton.userInteractionEnabled = YES; 
    
    [cell.rightButton setImage:[UIImage imageNamed:@"options.png"] forState:UIControlStateNormal]; 
    [cell.rightButton addTarget:self action:@selector(showOptions:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.rightButton setUserInteractionEnabled:YES]; 
    

    또는 당신은 또한 당신의 버튼에 탭 제스처을 추가 할 수 있습니다, 그것은 문제를 해결하는 것 대신이 라인의 ,

    [cell.rightButton addTarget:self action:@selector(showOptions:) forControlEvents:UIControlEventTouchUpInside]; 
    

    쓰기 이

    UITapGestureRecognizer *tap = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(showOptions:)]; 
    cell.rightButton addGestureRecognizer:tap]; 
    [cell.rightButton setUserInteractionEnabled:YES]; 
    
    +0

    나는 당신의 제안을 모두 시도했다. 하지만 여전히 iPad에 대한 응답이 없습니다. –

    0

    좋아, 나는 som 웬지 :

    iPad의 경우 버튼이 처음 320 픽셀 사이에있는 경우에만 응답합니다.

    (lldb) po touches 
    (NSSet *) $1 = 0x08249cd0 {(
    <UITouch: 0x82c63d0> phase: Began tap count: 1 window: <UIWindow: 0x8266ca0; 
    frame = (0 0; 768 1024); opaque = NO; autoresize = RM+BM; 
    layer = <UIWindowLayer: 0x8266d60>> view: <SBMultiCell: 0x82cb8a0; baseClass = UITableViewCell; 
    frame = (0 0; 744 93); autoresize = W; layer = <CALayer: 0x82cb830>> 
    location in window: {713, 123} previous location in window: {713, 123} 
    location in view: {701, 44} previous location in view: {701, 44} 
    )} 
    
    (lldb) po rightButton 
    (UIButton *) $2 = 0x082cd500 <UIButton: 0x82cd500; 
    frame = (658 0; 86 86); opaque = NO; layer = <CALayer: 0x82cd5e0>> 
    

    터치 위치가 버튼의 크기 사이에 정확히에서이며, 또한 모든 것이 제대로 그려 : 여기

    은 (오른쪽에 멀리 배치) 버튼을 터치 할 때 디버거의 말씀입니다. 그리고 이전에 썼듯이 겹쳐진 요소 등은 없습니다 ...

    관련 문제