Crear un archivo XI ter:
Archivo -> Nuevo Archivo -> ios-> cacao clase táctil -> siguiente
crea marca de verificación seguro "también crean archivos XI ter"
me gustaría realizar con tableview
así que choosed subclase UITableViewCell
se puede elegir como su requerment
archivo XI ter diseño como desee (RestaurantTableViewCell.xib)
tenemos que agarrar el alto de fila para establecer la mesa cada fila hegiht
Ahora! Necesito darles un rápido archivo. Me dieron mala suerte el restaurantPhoto
y el restaurantName
que les puedo dar a todos.
Ahora la adición de un UITableView
nombre
El nombre del archivo de la semilla, que no necesita incluir la extensión .nib.
propietario
El objeto asignar como objeto del propietario del archivo de la punta.
opciones
un diccionario que contiene las opciones para utilizar al abrir el archivo de la plumilla.
primera si no se define primero y luego grabing todo punto de vista .. Así que hay que agarrar una vista interior de ese conjunto frist
.
Bundle.main.loadNibNamed("yourUIView", owner: self, options: nil)?.first as! yourUIView
aquí es mesa de controlador de vista de código completo
import UIKit
class RestaurantTableViewController: UIViewController ,UITableViewDataSource,UITableViewDelegate{
override func viewDidLoad() {
super.viewDidLoad()
// Do any additional setup after loading the view.
}
override func didReceiveMemoryWarning() {
super.didReceiveMemoryWarning()
// Dispose of any resources that can be recreated.
}
func numberOfSections(in tableView: UITableView) -> Int {
return 1
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return 5
}
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let restaurantTableviewCell = Bundle.main.loadNibNamed("RestaurantTableViewCell", owner: self, options: nil)?.first as! RestaurantTableViewCell
restaurantTableviewCell.restaurantPhoto.image = UIImage(named: "image1")
restaurantTableviewCell.restaurantName.text = "KFC Chicken"
return restaurantTableviewCell
}
// set row height
func tableView(_ tableView: UITableView, heightForRowAt indexPath: IndexPath) -> CGFloat {
return 150
}
}
has hecho :)
Nota, este questin es arcaico. Durante muchos años, simplemente use vistas de contenedor [tutorial] (http://stackoverflow.com/questions/23399061/objective-c-how-to-add-a-subview-that-has-its-own-uiviewcontroller/23403979 # 23403979) – Fattie