我正在尝试在UITableViewCell. 我有一个UITextView和一个UIImageView(在顶部)。当存在本对于给定的细胞图像,该图像将是取消隐藏和排除路径将在被设定textContainer范围内的UITextView。当没有图像时,textContainer.exclusionPaths设置为nil。问题是当没有图像时,排除路径保持设置,有时反之亦然(设置了排除路径,但文本不会换行)。我使用dequeueCellWithIdentifier中UITableView并调用我的函数setFields(内cellForRowAtIndexPath)。当单元格被重新初始化时,排除路径大部分时间都在工作。我认为这与时间有关。任何帮助表示赞赏。
func setFields(avatar:UIImage?, author:String?, text:String?, images:[AnyObject], timestamp:String?){
....
self.thumbImageView.image = nil
self.thumbImageView.imageURL = nil
self.thumbImageView.hidden = true
self.titleText.textContainer.exclusionPaths = nil
if images.count > 0 {
self.images = images
if images is [UIImage] {
self.thumbImageView.image = images[0] as? UIImage
} else {
self.thumbImageView.imageURL = NSURL(string: images[0] as String)
}
self.cycleToImage(0)
self.thumbImageView.hidden = false
let convertedFrame:CGRect = self.titleText.convertRect(self.thumbImageView.frame, fromView: …Run Code Online (Sandbox Code Playgroud)