0
我发现了几个类似的问题,但没有回答我的问题。我希望用户选择一个表格单元格,打开相机,拍摄照片,并将该照片加载到表格单元格中的imageView中。这是我的代码到目前为止的一个片段。我只是失去了如何将这张照片添加到表格单元格中。谢谢!在表格视图中显示从相机拍摄的照片
func imagePickerController(picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [NSObject : AnyObject]){
imagePicker.dismissViewControllerAnimated(true, completion: nil)
var photo = info[UIImagePickerControllerOriginalImage] as? UIImage
}
func numberOfSectionsInTableView(tableView: UITableView) -> Int {
return 1
}
func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return bedroomCells.count
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier(textCellIdentifier, forIndexPath: indexPath) as UITableViewCell
let row = indexPath.row
cell.textLabel?.text = bedroomCells[row]
//cell.imageView?.image =
return cell
}
您需要定义视图基于表视图,把一个NSImage中的细胞在列。当您将其出列时,您需要将图像放置在该单元格中,并将显示在表格中。 – 2015-04-03 21:58:18
我不确定我是否清楚这一点,但我看到的方式是这样的。当用户点击你的一个tableviewcell时,didSelectRowAtIndexPath被调用,你的相机打开,拍照并存储在你的数组中。然后你重新加载tableview,它应该从数组中获取图像。 – anasimtiaz 2015-04-03 22:01:07
是的,这正是我想要做的。所以最佳做法是将拍摄在相机上的图像保存到数组中,然后在cellForRowAtIndexPath中检索该图像? – Cassandra 2015-04-03 22:30:50