3

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.

Tom
  • 26,212
  • 21
  • 100
  • 111
Keith
  • 43
  • 3
  • 9

1 Answers1

3

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
  • 10,879
  • 7
  • 50
  • 81