我试图根据不同的字符串长度计算UILabel的高度.
func calculateContentHeight() -> CGFloat{
var maxLabelSize: CGSize = CGSizeMake(frame.size.width - 48, CGFloat(9999))
var contentNSString = contentText as NSString
var expectedLabelSize = contentNSString.boundingRectWithSize(maxLabelSize, options: NSStringDrawingOptions.UsesLineFragmentOrigin, attributes: [NSFontAttributeName: UIFont.systemFontOfSize(16.0)], context: nil)
print("\(expectedLabelSize)")
return expectedLabelSize.size.height
}
Run Code Online (Sandbox Code Playgroud)
以上是我用来确定高度但不起作用的当前功能.我非常感谢能得到的任何帮助.我会在Swift中给出答案而不是Objective C.
我创建了UITableView一个自定义UITableViewCell.我的单元格包括UIImageView左侧和UITextView右侧的单元格.
在里面UITableViewController,我在tableview中设置了图像和文本cellForRowAtIndexPath.
一切都显示正常,但现在我需要实现didSelectRowAtIndex我需要区分是否UIImageView或UITextView细胞已被点击.
假设图像点击表示删除操作和其余的单元格编辑操作.