Quote:
Originally Posted by Oliver Drobnik
set delegate like this:
GraphView *myGraphView; // variable to hold pointer, could be in header of viewcontroller
myGraphView.delegate = self; // sets it to where you are currently
you don't need to set it to itself though, I think. Usually you would have delegate functions in the viewcontroller.
A Viewcontroller has some things that a view itself cannot do, like being pushed ontop of a navigationcontroller. Check the docs: UIViewController versus UIView. You very rarely need to subclass UIView only if you have very special drawing logic.
Unfortunately my MBP is being serviced as we speak, otherwise I would have offered that you send me the source and I find the problem for you.
cheers
Oliver
Dr. Touch
|
Thanks!
I did set the view in my controller header file, but not the self thing.
Looks like this:
Code:
#import <UIKit/UIKit.h>
#import "ChartView.h"
@interface WeightApp2ViewController : UIViewController {
IBOutlet UITextField *txtWeight;
IBOutlet UITextField *txtHeight;
IBOutlet UILabel *lblBmi;
ChartView *chartView;
}
@property(nonatomic,retain) IBOutlet UITextField *txtWeight;
@property(nonatomic,retain) IBOutlet UITextField *txtHeight;
@property(nonatomic,retain) IBOutlet UILabel *lblBmi;
- (IBAction) calculateBmi:(id) sender;
@end
and the implementation of the controller:
Code:
#import "WeightApp2ViewController.h"
@implementation WeightApp2ViewController
@synthesize txtWeight, txtWeight, lblBmi;
- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle*)nibBundleOrNil {
if (self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil]) {
// Custom initialization
}
return self;
}
- (void)loadView {
NSLog(@"chartView loading");
chartView = [[ChartView alloc] initWithFrame:CGRectMake(1.0, 0.0, 1.0, 1.0)];
[chartView setNeedsDisplay];
}
Gona test your solution when I get home from work
/x