How to change Custom Cell's UILabel Text?

Vimzy

I have a table view with a custom protoype cell and the cell has 3 different labels on it. How do I get access to these labels? I need to change their texts. I've searched around everywhere and haven't found something that helps me in this case. I have the below code:

-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:@"basicCell" forIndexPath:indexPath];

    //change cell's 3 labels' text here

    return cell;


}

How can I access the above cell's 3 different labels that it has?

Schemetrical

You need to make a class that is a subclass of UITableViewCell, and set the custom cell's class to the class you made. Then you want to link the labels using IBOutlets in the cell to the subclass you made.

Finally, in -tableView:cellForRowAtIndexPath:, you should cast the cell to your new subclass so you get access to those IBOutlets. Assuming your outlets are named someLabelOutlet1, someLabelOutlet2, and someLabelOutlet3, do the following after you finished subclassing.

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {

    SomeTableViewCellSubclass *cell = (SomeTableViewCellSubclass *)[tableView dequeueReusableCellWithIdentifier:@"basicCell" forIndexPath:indexPath];

    cell.someLabelOutlet1.text = @"sometext"
    cell.someLabelOutlet2.text = @"sometext"
    cell.someLabelOutlet3.text = @"sometext"

    return cell;
}

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to animate text color change partially in UILabel with custom control?

From Dev

set uilabel's text that added in uitableview cell

From Dev

Change text color of UILabel inside Custom UICollectionViewCell

From Dev

UILabel in custom UITableView cell not updating with Core Data change

From Dev

How to change height of custom cell on button's click?

From Dev

Resize Custom cell with a UILabel on it based on content text from JSON file

From Dev

How to change ListView cell's text color in JavaFX using css

From Dev

How to change an UIImageView into a custom cell

From Dev

How to change UILabel text with user typing message

From Dev

How to change text UILabel in swift code?

From Dev

Change UILabel text of custom UIView doesn't work

From Dev

Adding UILabel in custom cell issue

From Dev

how to make Dynamically Cell size Adjustment According to UIlabel text size

From Dev

How to break UILabel's text on characters, not on words

From Dev

How to break UILabel's text on characters, not on words

From Dev

Animate Text Change of UILabel

From Dev

How to change Datasource from custom cell class

From Dev

How to change the format of the cell in Excel COM to Text

From Dev

How to change text of the top left cell of a datagridview?

From Dev

How to update UILabel text in custom class after initialization (Swift 3)

From Dev

How to add custom text to a cell based on a specific entry in a different cell?

From Dev

Changing UILabel's text

From Dev

UIlabel's text truncation

From Dev

How to change UILabel size as per text with limited width

From Dev

How to change UILabel width based on text length in iOS?

From Dev

How to change the vertical align of text in a UILabel (iOS8)

From Dev

How to change UILabel size as per text with limited width

From Dev

How do I get a UILabel text to change randomly?

From Dev

UiLabel text assignment in custom view

Related Related

  1. 1

    How to animate text color change partially in UILabel with custom control?

  2. 2

    set uilabel's text that added in uitableview cell

  3. 3

    Change text color of UILabel inside Custom UICollectionViewCell

  4. 4

    UILabel in custom UITableView cell not updating with Core Data change

  5. 5

    How to change height of custom cell on button's click?

  6. 6

    Resize Custom cell with a UILabel on it based on content text from JSON file

  7. 7

    How to change ListView cell's text color in JavaFX using css

  8. 8

    How to change an UIImageView into a custom cell

  9. 9

    How to change UILabel text with user typing message

  10. 10

    How to change text UILabel in swift code?

  11. 11

    Change UILabel text of custom UIView doesn't work

  12. 12

    Adding UILabel in custom cell issue

  13. 13

    how to make Dynamically Cell size Adjustment According to UIlabel text size

  14. 14

    How to break UILabel's text on characters, not on words

  15. 15

    How to break UILabel's text on characters, not on words

  16. 16

    Animate Text Change of UILabel

  17. 17

    How to change Datasource from custom cell class

  18. 18

    How to change the format of the cell in Excel COM to Text

  19. 19

    How to change text of the top left cell of a datagridview?

  20. 20

    How to update UILabel text in custom class after initialization (Swift 3)

  21. 21

    How to add custom text to a cell based on a specific entry in a different cell?

  22. 22

    Changing UILabel's text

  23. 23

    UIlabel's text truncation

  24. 24

    How to change UILabel size as per text with limited width

  25. 25

    How to change UILabel width based on text length in iOS?

  26. 26

    How to change the vertical align of text in a UILabel (iOS8)

  27. 27

    How to change UILabel size as per text with limited width

  28. 28

    How do I get a UILabel text to change randomly?

  29. 29

    UiLabel text assignment in custom view

HotTag

Archive