为什么没有调用drawRect方法?

时间:2010-05-11 14:15:37

标签: 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];
   }

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

由于

3 个答案:

答案 0 :(得分:5)

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

答案 1 :(得分:3)

drawRect:是一种UIView方法,而不是UIViewController方法。

答案 2 :(得分:0)

我得到了答案,我从UIVIEW继承了一个新课程,我发现了没有调用的drawRect方法..

错误,我在UIVIEWCONTRLLER CLASSS中声明了这个方法,而不是我必须这样做 来自UIView的新课程。

相关问题