[英]Swift. Detecting when facebook login viewcontroller is being dismissed
[英]Swift. Viewcontroller aware of Subclass
我有一個tableview單元格的子類。
class profileTableViewCell: UITableViewCell {
@IBOutlet weak var tableviewUsernameLabel: UILabel!
@IBOutlet weak var tableviewMessageLabel: UILabel!
@IBOutlet weak var tableviewTimeStamp: UILabel!
}
我需要在我的viewcontroller中訪問這些標簽。 我該怎么做。 我是編程新手。
-我在下面的標簽上過分地看到“無法解析的標識符”。 如何訪問這些標簽?
-還嘗試將cell.tableViewUsername.text(cell。)放在所有標簽的前面仍然不起作用。
class UserProfile: UIViewController, UIImagePickerControllerDelegate, UINavigationControllerDelegate, UITableViewDataSource, UITableViewDelegate, UITextFieldDelegate{
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
let cell = profileTableView.dequeueReusableCell(withIdentifier: "profileCell")
//Set username label to display username
let usernameLabel = cell?.viewWithTag(1) as! UILabel
tableviewUsernameLabel.text = profileDataArray[indexPath.row].username
//Set message label to display message
let messageLabel = cell?.viewWithTag(2) as! UILabel
tableviewMessageLabel.text = profileDataArray[indexPath.row].message
tableviewMessageLabel.numberOfLines = 0
//Set timeStampLabel to current time AGO
let timeStampLabel = cell?.viewWithTag(4) as! UILabel
tableviewTimeStamp.text = profileDataArray[indexPath.row].timeStamp
tableviewTimeStamp.numberOfLines = 0
return cell!
}
func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
return profileDataArray.count // your number of cell here
}
}
您必須將由dequeueReusableCell(withIdentifier:)
返回的單元格類型 dequeueReusableCell(withIdentifier:)
為profileTableViewCell
。
let cell = profileTableView.dequeueReusableCell(withIdentifier: "profileCell") as! profileTableViewCell
cell.tableviewUsernameLabel.text = ...
cell.tableviewMessageLabel.text = ...
cell.tableviewTimeStamp.text = ...
return cell
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.