开发者

DrawRect is not displaying the image

In my Application am trying to display an image in a rectangle and am using DrawRect method.The problem is at the output am seeing nothing.Only blank screen in simulator.Here is the co开发者_Go百科de:

 - (void)viewDidLoad {
      [super viewDidLoad];
      [self drawRect:CGRectMake(78, 43, 222, 138)];
 }

 - (void)drawRect:(CGRect)rect {

    UIImage *myImage = [UIImage imageNamed:@"btbp.jpg"];

    CGRect imageRect = CGRectMake(10, 10, 300, 400);

    [myImage drawInRect:imageRect];
    //[self setNeedsDisplay];

    [myImage release];
}


there is no effect in invoking drawRect. instead you should invoke setNeedsDisplay to enforce redrawing.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜