0
이것은 내 프로그램이다. 나는 초보자이지만 빌드는 성공했지만 달리기는 멈춘다.나는이 프로그램 스택에 들어가거나 작동을 멈춘다.
import UIKit
class ViewController: UIViewController,UITableViewDelegate,UITableViewDataSource {
var items = [String]()
@IBOutlet var textField: UITextField!
@IBOutlet weak var tableView: UITableView!
@IBAction func addButton(sender: UIButton) {
let newItem = textField.text
items.append(newItem!)
textField.resignFirstResponder()
}
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view, typically from a nib.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return items.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath:
NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Cell",forIndexPath: indexPath)
cell.textLabel?.text = items[indexPath.row]
cell.textLabel?.textColor = UIColor.redColor()
return cell
}
}
빌드는 내가 0 또는 전무 당신이 도와 드릴까요 보여주는 흐름을 스택에 오류가 실행에 성공?
처럼 IBAction를에 추가하여
datasource
시도
newItem
을 추가 한 후tableView.reloadData()
누락 생각 – Israel