【发布时间】:2015-05-13 18:02:01
【问题描述】:
我正在尝试使用 Swift 编程开发一个在 Xcode 中使用 tableView 的应用程序。我已经在 tableView 中显示了图像,但图像不是全尺寸。图像仍然没有覆盖单元格的区域。
如何使图像全尺寸?
我正在使用 Xcode 6 并使用 Swift Programming。
下面是代码示例。
class FoodListTableViewController: UITableViewController {
var food:AnyObject?
override func viewDidLoad() {
super.viewDidLoad()
let path = NSBundle.mainBundle().pathForResource("food", ofType: "plist")
let food2 = NSArray(contentsOfFile:path!)
food = food2!
}
override func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return food!.count
}
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("cellfood", forIndexPath: indexPath) as! UITableViewCell
var imageName = UIImage(named: food![indexPath.row].objectForKey("gambar")! as! String)
cell.imageView!.image = imageName
return cell
}
这是我得到的屏幕截图...
http://104.223.3.210/namia/hm/Screen%20Shot%202015-05-14%20at%202.02.47%20AM.png
【问题讨论】:
-
你说的是左边的空白吗?
-
@Amit89 yes..left hand side
-
这是当前iOS版本的默认设置。
标签: ios xcode uitableview swift