내 앱의 기본 화면으로 표를 만들려고하는데 문제가 있습니다. main.storyboard를 올바르게 설정했지만, "superclass를 오버라이드하지"않는 override func가 있습니다. 오류는 nuberOfRowsInSection 재정의 기능 행에 있습니다. 내 코드는 다음과 같습니다.신속한 테이블 뷰 컨트롤러 설정?
import UIKit
class ViewController: UITableViewController {
var candies = [Candy]()
@IBOutlet weak var editButton: UIButton!
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup
// after loading the view.
self.candies = [Candy(name: "Jolly Rancher"),Candy(name: "Snickers"),Candy(name: "Twix"),Candy(name: "Butterfinger"),Candy(name: "Milky Way")]
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
override func tableView(tableView: UITableView, nuberOfRowsInSection section: Int) -> Int {
return self.candies.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = self.tableView.dequeueReusableCellWithIdentifier("Cell", forIndexPath: indexPath) as UITableViewCell
var candy : Candy
candy = candies [indexPath.row]
cell.textLabel?.text = candy.name
}
@IBAction func editButtonPressed(sender: UIButton) {
editButton.setTitle("Save", forState: UIControlState.Normal)
}
}
맞춤법 오류가 발생했습니다. 그러나 cell.textLabel? .text = candy.name 뒤에 오류가있는 경우 닫기 오류가 수정되었습니다. –
오류가 무엇입니까? – Christian
반환 할 함수에서 반환 값이 누락되었습니다. UITableViewCell –