Click here to Skip to main content
15,887,875 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have an xib file containing a custom cell. I'm trying to access the height of an object created in `customCell.m`.

Here is my code:

Objective-C
customCell.m

    - (void)awakeFromNib
    {
        self.label = [[UILabel alloc] initWithFrame:CGRectMake(0, 0, 50, 200)];
        [self.label setText:@"This is a label"];
        [self.myView addSubview:self.label];
    
        NSLog(@"%f", self.label.frame.size.height);  // Results: 200.0000
    }
    
mainViewController.m
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
    
        customCell *cellVC = [[cutsomCell alloc] init];
    
        NSLog(@"%f, %f", cellVC.label.frame.size.height); // Results: 0.0000
    }
Posted

1 solution

you must also overwrite the init function abd approbiate values. I normally write an setup function which is called in both.

PS: Read the Apple docs to understand the language and its concepts.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900