views:

79

answers:

2

Hello everyone,

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..

help????

A: 

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];
Dan Loewenherz
A: 

Hi Dan,

Yeah that works!!!! excellent!!

Thanks:)

Keith