1

I put label inside table cell. I changed the text color into "White" in Attributes inspector. I also changed the label background color into "Green".
When I run the app, the text color does not change into white color but background changed to green. I also put the code.

 cell.lblName.textColor = UIColor.white

I declare this @IBOutlet weak var lblAllowAutoRenew: UILabel! in MediaPackListCell.swift file.

In TableView.swift,

 func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {

 let cell = tableView.dequeueReusableCell(withIdentifier: "planCell",for: indexPath) as! MediaPackListCell

 cell.lblAllowAutoRenew.textColor = UIColor.white

}


Each cell has detail disclosure.
Nothing is working .... :(
This case is so strange for me. I dragged the label into UI and select the label and then change the color. But, it does not work.
Could anyone help me please?

May Phyu
  • 895
  • 3
  • 23
  • 47

1 Answers1

0

Try replacing line below

 let cell = tableView.dequeueReusableCell(withIdentifier: "planCell",for: indexPath) as! MediaPackListCell

with

 let cell = tableView.dequeueReusableCell(withIdentifier: "planCell",for: indexPath) as! Tablecell

And make sure you are using right reuse identifier "planCell" , which you have used for Tablecell.swift

Harshad Madaye
  • 480
  • 1
  • 7
  • 21
  • bro I'm sorry. I wrote wrong name swift file in here. I edit it. Could you anything help me please? – May Phyu Jul 17 '17 at 16:27
  • have you cross checked if you are using right reuse identifier. – Harshad Madaye Jul 19 '17 at 07:25
  • 1
    Yes. I found the problem bro. Simple label does not have any problem. But I check the condition in it. For eg. if label value is equal to 1 , then cell.lblAllowAutoRenew.text = "Allow" and if it is not equal to 1, then cell.lblAllowAutoRenew.text = "Not Allow" . The problem occurs at that place. I also put this code cell.lblAllowAutoRenew.textColor = UIColor.white under each condition. But, it does not work. So, if I remove all that condition, the label appears as I want to be bro. – May Phyu Jul 19 '17 at 07:30
  • Just know the error but haven't known the solution to trick this process. :D – May Phyu Jul 19 '17 at 07:46