Reputation: 43
In my Project, I have a customised @interface GraphView: UIView
. Hence GraphView
is a subclass of UIView
and is meant to show a graph.
Then, I create a new View Controller called Summary
using a NIB. In the Interface builder, I just add a UIToolbar
at the bottom of the View.
In the implementation of Summary
, in the viewDidLoad
method, I have the following code:
-(void)viewDidLoad {
[super viewDidLoad];
GraphView *myGraph = [[GraphView alloc]init];
[self.view addSubview:myGraph]; //this does not work
}
But I am unable to get this.
Upvotes: 3
Views: 5349
Reputation: 11236
I believe you need to set the frame of myGraph
before you add it as a subview to self
.
CGRect rect = CGRectInset(self.view.bounds, 0.0, 0.0);
GraphView *myGraph = [[GraphView alloc] initWithFrame:rect];
[self.view addSubview:myGraph];
Upvotes: 3