我正试图创造这种外观:
现在我有这个:
三个原型单元格,分别是从上到下的标识符和自定义单元格
ID
cellStyle
cellStyle2
cellStyle3
自定义单元格类只有大写C。
到目前为止,这是我的代码:
我要做的是将出队单元格更改为我的不同自定义单元格类,以便能够访问其属性并更改标签和UIImageView。此方法无效cell.label.text
无法识别。我也尝试为这样的单元创建三个不同的变量。
var cellStyle: CellStyle
var cellStyle2: CellStyle2
var cellStyle3: CellStyle3
那么我对return
的功能是什么?
问题:
layer.borderColor
layer.borderWidth
layer.cornerRadius
layer.masksToBounds
numberOfRowsInSection
?这是我之前基于评论的代码的更新。
override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell {
switch indexPath.row {
case 0:
var cell = tableView.dequeueReusableCellWithIdentifier("cellStyle", forIndexPath: indexPath) as! cellStyle
cell.label?.text = "Friends"
// Configure cell
case 1:
var cell = tableView.dequeueReusableCellWithIdentifier("cellStyle2", forIndexPath: indexPath) as! cellStyle2
// Configure cell
cell.label?.text = "Random"
case 2:
var cell = tableView.dequeueReusableCellWithIdentifier("cellStyle", forIndexPath: indexPath) as! cellStyle
// Configure cell
cell.label?.text = "Judge"
default:
// Default cell with no text
cell.textLabel?.text = ""
}
switch indexPath.section {
case 0:
var cell = tableView.dequeueReusableCellWithIdentifier("cellStyle3", forIndexPath: indexPath) as! cellStyle3
// Configure cell
cell.label?.text = "" // TODO: Need to put name from opponent _User reference into here
// cell.friendProfilePic.image = //Query facebook api for profile picture of friend with Facebook ID for "opponent"
case 1:
var cell = tableView.dequeueReusableCellWithIdentifier("cellStyle3", forIndexPath: indexPath) as! cellStyle3
// Configure cell
cell.label?.text = "" // TODO: Need to put name from opponent _User reference into here
// cell.friendProfilePic.image = //Query facebook api for profile picture of friend with Facebook ID for "opponent"
case 2:
var cell = tableView.dequeueReusableCellWithIdentifier("cellStyle3", forIndexPath: indexPath) as! cellStyle3
// Configure cell
cell.label?.text = "" // TODO: Need to put name from opponent _User reference into here
// cell.friendProfilePic.image = //Query facebook api for profile picture of friend with Facebook ID for "opponent"
default:
// Default cell with no text
cell.textLabel?.text = ""
}
// Configure the cell...
return cell
}