Администратор может добавлять изображение/текст, отображает содержимое, но изображение не делает его после добавления. Мне нужно добавить текст, чтобы отобразить изображение. Например, я могу добавить много изображений, они находятся в таблице, но они не будут просматриваться до тех пор, пока администратор не добавит текст.Tableviewcell не отображает изображение | Swift
Дело в том, что я конвертирую изображение в base64, добавляю к массиву и cellForRowAtIndexPath. Я его декодирую и добавляю в ячейку.
func imagePickerController(picker: UIImagePickerController, didFinishPickingImage image: UIImage, editingInfo: [String : AnyObject]?) {
var data = NSData()
data = UIImagePNGRepresentation(image)!
let base64String = data.base64EncodedStringWithOptions(NSDataBase64EncodingOptions.Encoding64CharacterLineLength)
let newImage = "imageBase64" + base64String
content.append(newImage)
self.dismissViewControllerAnimated(true, completion: nil)
}
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell{
if content[indexPath.row].rangeOfString("imageBase64") == nil {
let cell = self.articleTableView.dequeueReusableCellWithIdentifier("Text Cell", forIndexPath: indexPath) as! TextTableViewCell
cell.textArticle.text = content[indexPath.row] as String
return cell
}
else{
let cell = self.articleTableView.dequeueReusableCellWithIdentifier("Image Cell", forIndexPath: indexPath) as! ImageTableViewCell
let imageString = content[indexPath.row].stringByReplacingOccurrencesOfString("imageBase64", withString: "")
let decodedData = NSData(base64EncodedString: imageString, options: NSDataBase64DecodingOptions.IgnoreUnknownCharacters)
let decodedImage = UIImage(data: decodedData!)
cell.backgroundColor = UIColor.clearColor()
cell.imageArticle.image = decodedImage
return cell
}
Как сделать изображение отображаемым сразу?
ой лол, моя вина. Спасибо! –