테이블 뷰 컨트롤러가 있고 테이블 뷰 셀을 처리하는 별도의 클래스가 있습니다. tableview 셀 안에는 pickerview가 있습니다. tableCell 클래스에 있지만 테이블 뷰 컨트롤러에서 내 대리자 기능을하는 pickerview에 대한 대리자 및 데이터 소스를 구현하는 방법은 무엇입니까?UIPickerView + TableViewCell + 대리자 및 데이터 소스
1
A
답변
1
tableview 셀이 테이블 뷰 셀에 생성 될 때 위임자 및 데이터 소스임을 나타내는 속성을 설정할 수 있습니다.
당신이 만든 tableviewcell 클래스는 당신의 인스턴스 인 tableview 컨트롤러의 속성을 추가하기 만하면됩니다.
@property (nonatomic, retain) MyTableViewController * pickerDelegate;
이 그런 다음 cellForRowAtIndexPath 당신이 자기
cell.pickerDelegate = self;
해당 속성을 설정할 수 있습니다 마찬가지로 당신은 또한 각 셀을 구별하는 태그처럼 어떤 종류의 추가 속성을 설정해야 할 수도 있습니다. NSIndexPath 같은 tableviewcell 다른 속성을 할 것이라고 생각합니다. 스위프트를 들어
0
:
class MyTableViewCell: UITableViewCell, UIPickerViewDelegate, UIPickerViewDataSource {
@IBOutlet var myPickerView: UIPickerView!
}
가의 ViewController에서 "cellForRowAtIndexPath"의 위임 및 데이터 소스를 추가합니다 :
class myViewController: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource, UITableViewDelegate, UITableViewDataSource {
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("myCell") as! MyTableViewCell
cell.myPickerView.dataSource = self
cell.myPickerView.delegate = self
return cell
}
}
사용자 정의 테이블 뷰 클래스에 UIPickerView에 대한 출구를 만들기
관련 문제
- 1. UIPickerView 대리자 및 데이터 소스 메서드가 호출되지 않습니다.
- 2. UITableView의 대리자 및 데이터 소스 메서드
- 3. plist를 사용해야하는 경우, UIPickerView 데이터 소스 도움말
- 4. UIPickerView 데이터
- 5. UIPickerView, 정적 데이터
- 6. iphone의 UIPickerView
- 7. 자체 UIToolbar가있는 UITextView 및 UIPickerView
- 8. IPad + UIPickerView
- 9. iPhone UIPickerView 및 배열
- 10. UIPickerView 및 NSUserDefaults 문제
- 11. UITextField 및 UIPickerView
- 12. UIPickerView 및 거대한 연락처 목록?
- 13. 동적으로 Textview- 및 TableviewCell 행 높이를 변경하십시오.
- 14. TableViewCell, backgroundView 및 selectedBackgroundView를 서브 클래스 화하기
- 15. UIPickerView
- 16. 두 개의 UIPickerView 객체가 동일한 데이터 소스 배열을 공유 할 수 있습니까?
- 17. cx_Oracle 및 데이터 소스 패러다임
- 18. C# 상수 및 대리자
- 19. 익명 메서드 및 대리자
- 20. 대리자 및 여러 메서드
- 21. 대리자 및 상속 C#
- 22. 대리자 및 콜백
- 23. 사용자 정의 TableViewCell 높이는
- 24. 사용자 지정 TableViewCell 질문
- 25. 자세히보기 tableviewcell 밖으로
- 26. iPhone - UIPickerView 및 UIWebView의 제스처
- 27. iPad 및 UIPickerView (또는 UIDatePickerView)
- 28. iPhone Xcode 4 picker 데이터 소스
- 29. UIPickerView 글꼴
- 30. XMLParser 대리자 및 메모리 누수
감사합니다. , 지금 시도해 볼 것입니다 ... –
이 작품을 위해 당신을 했습니까? – geekydevjoe