Я хочу сделать табличное представление с кнопкой в верхнем углу. Я хочу, чтобы кнопка добавила еще одну строку в таблицу, поэтому вы можете добавить изображение в ячейку или текст. У меня есть поиск через Интернет, но я не нашел ответа.Добавление строк в tableview с помощью кнопки
Вот исходный код:
import UIKit
class TableViewController: UITableViewController {
var imageArray = ["1","2","3","4","5","6","7"]
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.
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("Reccept") as UITableViewCell!
let imageView = cell.viewWithTag(2) as! UIImageView!
imageView.image = UIImage(named: imageArray[indexPath.row])
return cell
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return imageArray.count
}
}
Что вы пытаетесь, где действие кнопки? –