2011-06-11 2 views
6

재생 목록에 노래를 추가 할 때 각 셀에 iPod 앱처럼 '+'버튼이있는 TableView를 구현하려고합니다.AccessoryType TableView에 "Plus"버튼 추가

cell.accesoryType는 네 개의 값

UITableViewCellAccessoryCheckmark 

UITableViewCellAccessoryDetailDisclosureButton 

UITableViewCellAccessoryDisclosureIndicator

None 

방법이 작업을 수행 할 수있다? 맞춤 버튼을 만들고 cell.accessoryView을 설정해야합니까, 아니면 다른 방법이 있나요? 만약 당신이 custom cell를 작성하는 경우 당신은 또한 "이미지를보고"얻을 수 있도록

답변

0

후, 바로 accessory type 나타날 경우처럼, 오른쪽 모서리에 그것에 button를 놓고 버튼에 당신의 '+'이미지를 할당 「버튼 액션 이벤트」

맞춤형 uitableviewcells에 대한 this 자습서를 참조하십시오.

또한 setEditing:animated:
확인하려면 좀 걸릴 수 있습니다
+5

발견 된 솔루션 UIButton * button = [UIButton buttonWithType : UIButtonTypeContactAdd]; [button addTarget : 자기 액션 : @selector (buttonTapped : event :) forControlEvents : UIControlEventTouchUpInside]; cell.accessoryView = button; 및 절차 이벤트 처리 생성 - buttonTapped (무효) : (ID) 보낸 이벤트 (ID) 이벤트를 { } – teo

12

테오의 솔루션은 잘 작동하지만,이 답변으로 게시되지 않은, 그래서 내가 다시 게시 해요 :

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd]; 
[button addTarget:self action:@selector(addbuttonTapped) forControlEvents:UIControlEventTouchUpInside]; 
cell.accessoryView = button; 
+0

그리고 그것은 당신이 upvote를 얻을 것을 의미합니다! – Saltymule

3

간단한에게 JosephH의 변형, 기억을 위해. 당신은 단순히 장식 "+"버튼을 원하고 원래 didSelectRowAtIndexPath 트리거, 사용을 계속 사용하는 경우

: 버튼을 사용자 상호 작용을 비활성화하면

UIButton *button = [UIButton buttonWithType:UIButtonTypeContactAdd]; 
[button setUserInteractionEnabled:NO]; 
cell.accessoryView = button; 

를, 그것은 기본보기에 압력 이벤트를 전달합니다 다음 세포.

관련 문제