从上到下依次将不同高度的自定义UIView添加到UITableViewcell中
Add custom UIView with different height into UITableViewcell one after another top to bottom
您好,我是 swift ios 的新手,我怎样才能将具有不同高度(取决于条件)的自定义 UIView 一个一个地添加到 UITableViewCell 中,一个在另一个下面。就像 iphone 中的提醒应用程序一样,但每个单元格都带有 different/same customViews - 取决于条件。最好的方法或做法是什么。谢谢大师们。
要在 UITableViewCell 中使用自定义视图,您必须添加一个 xib 文件并添加到 UITableViewCell 的 class 扩展。
要指定您的自定义视图和 UITablaView,您必须在此处进行:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell.
示例:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("yourCellIdentifier") as! CustomView
...
return cell
}
要设置自动高度和更多信息,您可以按照本教程进行操作:
dynamic table view cell height ios 8 swift
您好,我是 swift ios 的新手,我怎样才能将具有不同高度(取决于条件)的自定义 UIView 一个一个地添加到 UITableViewCell 中,一个在另一个下面。就像 iphone 中的提醒应用程序一样,但每个单元格都带有 different/same customViews - 取决于条件。最好的方法或做法是什么。谢谢大师们。
要在 UITableViewCell 中使用自定义视图,您必须添加一个 xib 文件并添加到 UITableViewCell 的 class 扩展。
要指定您的自定义视图和 UITablaView,您必须在此处进行:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell.
示例:
func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
let cell = tableView.dequeueReusableCellWithIdentifier("yourCellIdentifier") as! CustomView
...
return cell
}
要设置自动高度和更多信息,您可以按照本教程进行操作: dynamic table view cell height ios 8 swift