我正在开发简单的tableview应用程序,如屏幕截图所示,图像不是从左侧放置的。我的意思是它没有碰到左边界。
我的简单表视图的代码是:
class ViewController: UIViewController, UITableViewDelegate, UITableViewDataSource {
var iteams : [String] = ["Egg Benedict", "Mushroom Risotto", "Full Breakfast", "Hamburger", "Ham and Egg Sandwich", "Creme Brelee", "White Chocolate Donut", "Starbucks Coffee", "Vegetable Curry", "Instant Noodle with Egg", "Noodle with BBQ Pork", "Japanese Noodle with Pork", "Green Tea", "Thai Shrimp Cake", "Angry Birds Cake", "Ham and Cheese Panini"]
override func viewDidLoad() {
super.viewDidLoad()
// to get the class use the class name followed by .self
self.TableViewData.registerClass(UITableViewCell.self, forCellReuseIdentifier: "Cell")
}
@IBOutlet var TableViewData: UITableView!
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int{
return self.iteams.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
// Create the cell
var cell : UITableViewCell = self.TableViewData.dequeueReusableCellWithIdentifier("Cell") as UITableViewCell
cell.textLabel?.text = self.iteams[indexPath.row]
cell.imageView?.image = UIImage(named: "creme_brelee.jpg")
return cell
}
}
请告诉我任何解决方案。 提前谢谢。