공개 표시기가있는 특정 셀을 사용하여 UIImagePicker
(다른 셀은 UITextFields
등)을 표시하려고합니다. 지금까지는 UIButton
으로 만 수행 할 수있었습니다. 내 작업을 셀에 연결하려고하지만 내 유일한 옵션은 새로운 섹그를 만드는 것입니다. 어떻게하면 좋을까요?UITableViewCell을 액션에 연결
0
A
답변
1
사용자가 원하는 셀의 색인 경로 (목록의 첫 번째 셀 등)를 알고있는 경우. 그럼 당신은 사용할 수 있습니다 또한 이벤트 탭에 응답하지 않는 당신의 cellForRowAtIndexPath 다른 모든 세포를 설정할 예정
-(void) tableview:(UITableView *)tableview didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
if (indexPath.section == 0 && indexPath.row == 0) {
// do some action
[tableview deslectRowAtIndexPath:indexPath];
[self someAction];
}
}
. 하는 .m 파일에 IB
@property (weak, nonatomic) IBOutlet UITableViewCell *upgradeAppCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *spreadTheWordCell;
@property (weak, nonatomic) IBOutlet UITableViewCell *rateOnAppStoreCell;
를 사용하여 IBOutlets를 작성, .H 파일에
: 당신이 섹션 및 행의 인덱스를 하드 코드하지 않으려면
0
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath: (NSIndexPath *)indexPath
{
static NSString *identifier = @"identifier";
YourCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
if(!cell)
{
cell = /*Create your cell*/
[cell.button addTarget:self action:@selector(didClickButton:) forControlEvents:UIControlEventTouchUpInside];
}
cell.button.tag = [indexPath row];
return cell;
}
-(void)didClickButton:(UIButton *)button
{
int row = button.tag
/*Here you'll be able to know the button of which row has been clicked.*/
}
+0
인터페이스 빌더에서 전체보기를 거의 수행 했으므로 cellForRowAtIndexPath 메소드를 추가하여 복잡하게 만들고 싶지 않았습니다. – Andrew
1
, 당신은 이런 식으로 뭔가를 할 수 :
- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath
{
UITableViewCell *cell = [self.tableView cellForRowAtIndexPath:indexPath];
if (cell == upgradeAppCell)
{
[self upgradeApp];
}
else if (cell == spreadTheWordCell)
{
[self spreadTheWord];
}
else if (cell == rateOnAppStoreCell)
{
[self rateOnAppStore];
}
}
관련 문제
- 1. 링크를 열려면 UITableViewCell을 선택하십시오.
- 2. 링크 하나의 UITableViewCell을 두 개의 서로 다른 가장자리에 연결
- 3. UISearchBar를 액션에 묶기
- 4. UIComponent를 액션에 전달하십시오. ExampleExpression
- 5. Cocos2D에서 태그로 액션에 액세스하기
- 6. 마지막 UITableViewCell을 제거하는 방법
- 7. 편집에서 UITableViewCell을 제외하십시오
- 8. 강제로 UITableViewCell을 해제하는 방법
- 9. 커스텀 UITableViewCell을 생성해야합니까?
- 10. UITableViewCell을 편집 가능하게 만들기
- 11. 탭에서 UITableViewCell을 확장 하시겠습니까?
- 12. JSON Base64로 UITableViewCell을 채우시겠습니까?
- 13. UITableViewCell을 포함하는 UIButton
- 14. UITableViewCell을 선택하면 UIButton이 덮여집니다.
- 15. 설정에서 UITableViewCell을 선택하십시오.
- 16. uitableviewcell을 여러 번 클릭
- 17. UITableViewCell을 숨기는 방법?
- 18. UITableViewCell을 이미지로 내보내려면 어떻게해야합니까?
- 19. UITextField처럼 UITableViewCell을 만들려면 어떻게해야합니까?
- 20. UITableViewCell을 통한 UIPopoverController
- 21. UITableViewCell을 동적으로 크기 조정
- 22. 레일즈는 여러 액션에 버튼을 형성합니다
- 23. Struts2 : 액션에 입력 배열 읽기.
- 24. HtmlEditor - 컨트롤러의 액션에 전달하는 방법?
- 25. DateTime을 컨트롤러 액션에 전달하는 방법
- 26. iphone - cell.imageView를 사용하여 UITableViewCell을 검색합니다.
- 27. 애니메이션이있는 UITableViewCell을 추가/삭제 하시겠습니까?
- 28. 텍스트 상자와 버튼으로 UITableViewCell을 만드시겠습니까?
- 29. UItableviewcell을 다른 조건에 따라 정렬하기
- 30. 수동으로 UITableViewCell을 설정하는 방법은 무엇입니까?
왜 didSelectRowAtIndexPath를 사용하지 않으시겠습니까? – MCKapur
@LuisOscar, 어떻게 증가하는지 알려주세요. 나에게도 너무 적다. –
답을 정확하게 표시하는 것이 적절하다는 것을 알지 못했습니다. 감사합니다. (대부분의 내 질문에 올바른 답을 표시했습니다.) – Andrew