2014-11-20 4 views
0

여기에 UITableViewCell에 버튼이 있습니다. 버튼을 클릭하면 다른보기가 팝업됩니다. 동일한 버튼을 클릭하면보기가 비활성화되어야합니다. 이걸 도와주세요. 미리 감사드립니다.iOS에서 하위보기의 버튼을 클릭하는 동안 수퍼 뷰를 사용 중지하는 방법

-(UITableViewCell*)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath 
{ 
    UITableViewCell *cell  = (UITableViewCell *)[tableView dequeueReusableCellWithIdentifier:@"CellIdentifier"]; 

    if (cell == nil) 
    { 
     cell     = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleDefault reuseIdentifier:@"CellIdentifier"]; 
     cell.frame    = CGRectZero; 
     cell.backgroundColor = [UIColor whiteColor]; 
     cell.selectionStyle  = UITableViewCellSelectionStyleGray; 

     UILabel* label     = [[UILabel alloc] initWithFrame:CGRectMake(20, 0, 250, 50)]; 
     label.font      = [UIFont lightFontWithSize:14]; 
     label.textAlignment    = NSTextAlignmentLeft; 
     label.textColor     = [UIColor blackColor]; 
     label.highlightedTextColor  = [UIColor whiteColor]; 
     label.numberOfLines    = 2; 
     label.tag      = 1; 

     ForumDBFilePath* currObj = [forumResultArray objectAtIndex:indexPath.row]; 
     cell.textLabel.text = [NSString stringWithFormat:@"%@",currObj.postcontent]; 
     cell.textLabel.font = [UIFont regularFontWithSize:15]; 
     [cell.contentView addSubview:label]; 
     UIBackgroundButton* replyButton = [UIBackgroundButton buttonWithType:UIButtonTypeCustom]; 
     [replyButton setButtonColor:[UIColor whiteColor] setBackgroundColor:[UIColor getNavBarColor]]; 
     [replyButton setTitle:@"Reply" forState:UIControlStateNormal]; 
     replyButton.tag = indexPath.row; 
     [replyButton.titleLabel setFont:[UIFont mediumFontWithSize:14]]; 
     [replyButton setFrame:CGRectMake(viewWidth-0, 15, 125, 30)]; 
     [replyButton addTarget:self action:@selector(replyButton:) forControlEvents:UIControlEventTouchUpInside]; 
     [replyButton resignFirstResponder]; 
     [cell.contentView addSubview:replyButton]; 
    } 
    return cell; 
} 

답변

0

이 같은 수퍼 메소드를 오버라이드 (override) 할 수 있습니다

- (id)hitTest:(CGPoint)point withEvent:(UIEvent *)event { 
    id hitView = [super hitTest:point withEvent:event]; 
    if (hitView == self) { 
     return nil; 
    } else { 
     return hitView; 
    } 
} 

은 당신을 도움이되기를 바랍니다.

관련 문제