HurkNburkS
HurkNburkS

Reputation: 5510

load subview over self.view

I am trying to add a UIView over the current view, but having no luck.. I am sure my code is correct but not sure what else to check, what else should I be thikning about when inserting subviews

this is what I have added into viewDidLoad

//..
    cellContainer = [[UIView alloc] init];

    cellContainer.frame = CGRectMake(0.0, 480.0, 320.0, 300.0);

    [self.view addSubview:cellContainer];

    self.view.backgroundColor = [UIColor greenColor];
//..

cellContainer is declared in the header as a UIView... any help would be appreciated.

Upvotes: 0

Views: 64

Answers (1)

James
James

Reputation: 2282

cellContainer is likely getting added to the view hierarchy of of the UIViewController, but you've set the frame such that it is offscreen. Try this:

 cellContainer = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 320, 300)];
 [self.view addSubview:cellContainer];
 self.view.backgroundColor = [UIColor greenColor];

This will display cellContainer at the top left of the view, extending 320px in the right-x direction, and 300px in the down-y direction.

Upvotes: 4

Related Questions