2010-04-19 4 views
0

단추를 tableview에 추가하려고하는데 단추를 지정할 프레임이 보이지 않더라도. 이것은 사용자 정의 UITableViewCell이며 xib 파일 대신 코드에 단추를 추가하는 것이므로 단추를 클릭하고 didSelectRowAtIndexPath가 아닌 작업을 수행 할 수 있습니다. cellForRowAtIndexPath에 다음 코드가 있습니다. 있어야 할 곳에 없는?UITableView subview to uitableviewcell

UIButton *button = [UIButton buttonWithType:UIButtonTypeDetailDisclosure]; 
    button.frame = bframe; 
    button.userInteractionEnabled = YES; 
    [button addTarget:self action:@selector(buttonClick:) forControlEvents:UIControlEventTouchUpInside]; 
    [cell.contentView addSubview:button]; 
    return cell; 
+1

너무 길지 않은 경우 cellForRowAtIndexPath에 전체 코드를 표시하십시오. 버튼을 감추고있는 셀에 어떤 다른 컨트롤이 추가 되었습니까? cell.accessoryType = UITableViewCellAccessoryDetailDisclosureButton 및 accessoryButtonTappedForRowWithIndexPath를 사용하지 않는 이유는 무엇입니까? – DyingCactus

+0

감사합니다. UITableViewCellAccessoryDetailDisclosureButton 및 accessoryButtonTappedForRowWithIndexPath를 사용하여 작동하게했습니다. 회신에 감사드립니다. – Dave

답변

0

있는 UIButton의 * 버튼을 시도 = [있는 UIButton buttonWithType : UIButtonTypeDetailDisclosure] 유지];

+0

이 작동하지 않습니다. buttonWithType은 당신을 위해 할당과 autoRelease를한다. 그래서 나는 이것이 내가하는 것과는 다른 방법이 아니다. – Dave

+0

나는 내 대답에 업데이트 코드가 있는데, – Nnp

관련 문제