내 프로젝트에 https://github.com/intuit/AnimatedFormFieldTableViewCell을 사용하고 싶지만 설정 단계를 둘러 볼 수 없습니다. 지금까지, 나는 폴더에서 파일을 드래그하고 단계를 따라했습니다UITextFieldDelegate 구현
AnimatedFormFieldTableViewCell
을 사용하기 위해서는, 당신이해야 할 모든입니다 :
1)는의 ViewController에 AnimatedFormFieldTableViewCell
펜촉 등록을하는에 재사용 식별자를 위해 UITableView를 구현하고있다.
override func viewDidLoad() {
super.viewDidLoad()
self.tableView.registerCellNib(AnimatedFormFieldTableViewCell)
tableView.reloadData()
}
2) CellForRowAtIndexPath에서 AnimatedFormFieldTableViewCell로 셀을 축약합니다.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "cell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! AnimatedFormFieldTableViewCell
return cell
}
3) 셀 자체에서 setLabelText를 호출하여 자리 표시 자의 레이블 텍스트를 변경합니다.
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cellIdentifier = "cell"
let cell = tableView.dequeueReusableCellWithIdentifier(cellIdentifier, forIndexPath: indexPath) as! AnimatedFormFieldTableViewCell
cell.setLabelText("Enter title")
return cell
}
주 :
1), 당신은 단지 AnimatedFormFieldTableViewCell의 위임 (직접의 위임을 정의 할 필요가 없습니다를 정의 할 필요가 당신은 여전히 UITextFieldDelegate 당신이 정기적으로의 UITextField에 구현하는 것과 같은 방법을 구현할 수 있습니다 포함 된 UITextField).
2) 포함 된 UITextField에 액세스하려면 단순히 셀의 cellTextField 속성을 호출하면됩니다. 내 응용 프로그램을 실행하는 경우
I don’t get these last two steps.
, 나는 AnimatedFormFieldTableViewCell
클래스 self.cellTextfield.delegate = self
에 unexpectedly found nil
를 얻을.
무엇이 누락 되었습니까?
You just need to define the AnimatedFormFieldTableViewCell's delegate
당신은 cellTextField
보다는 AnimatedFormFieldTableViewCell
의 대리자를 설정할 수 있습니다 :
There is no need to directly define the delegate for the embedded UITextField
명령은 다음을 수행하는 것입니다
당신이'cellTextField'에 액세스하는 신속한 버전에 따라 다를 수 있다는 것을 알고? 그 코드도 포함시켜 주시겠습니까? 문서에는 명시 적으로 '임베디드 UITextField에 대한 위임을 직접 정의 할 필요가 없습니다.'라는 메모가 명시되어 있습니다. self.cellTextField.delegate보다는 원하는 delegate에'self.delegate'를 설정해야합니다. –
@MichaelFourre 나는 그것을 얻지 않는다. 나는'cellTextField'에 접근하고 있지 않습니다. 'UITextFieldDelegate'도 구현하지 않습니다. 나는 어떻게해야할지 모르겠다. 'self.cellTextField.delegate'는 에러가 발생합니다. 이것은'AnimatedFormFieldTableViewCell' 클래스에서 구현되었으며 내 클래스에서는 구현되지 않습니다. – waseefakhtar
@MichaelFourre'cellTextField'에 액세스하지 못하는 이유는 아마도 예기치 않게 발견 된 nil 오류가 발생하는 이유 일 것입니다. 그러나 나는 그것을 올바르게 구현하기 위해 단계를 순차적으로 따라 가고 싶다. – waseefakhtar