为什么没有调用drawRect方法?

Rah*_*hul 0 iphone drawrect

#import <UIKit/UIKit.h>

@interface quartzViewController : UIViewController {
 IBOutlet UIView *myView;

}

@end


#import "quartzViewController.h"

@implementation quartzViewController


   -(void)drawRect:(CGRect)rect
   {   

 CGContextRef  context = UIGraphicsGetCurrentContext();
 CGContextSelectFont(context, "Arial", 24, kCGEncodingFontSpecific);
 CGContextSetTextPosition(context,80,80);
 CGContextShowText(context, "hello", 6);
 //not even this works
 CGContextShowTextAtPoint(context, 1,1, "hello", 6);
   }

   - (void)viewDidLoad {
 [myView setNeedsDisplay];

 [super viewDidLoad];
   }
Run Code Online (Sandbox Code Playgroud)

我是否必须在笔尖中进行任何更改?

谢谢

Mel*_*emi 5

你已经将UIViewController子类化了,它没有要覆盖的drawRect.drawRect是UIView的一种方法.