why my iphone device and simulator has different screen resolution?

Posted by happyzone8 on Stack Overflow See other posts from Stack Overflow or by happyzone8
Published on 2011-01-04T00:41:12Z Indexed on 2011/01/04 0:53 UTC
Read the original article Hit count: 178

Filed under:
|

i use itouch 4G has my device and i use simulator-4.2
i will just draw a rectangle as an example. i use Quartz-2d to draw

- (void)drawRect:(CGRect)rect { 
// Get a graphics context, saving its state
CGContextRef context = UIGraphicsGetCurrentContext();
CGContextSaveGState(context);

// Reset the transformation
CGAffineTransform t0 = CGContextGetCTM(context);
t0 = CGAffineTransformInvert(t0);
CGContextConcatCTM(context,t0);

// Draw a green rectangle
CGContextBeginPath(context);
CGContextSetRGBFillColor(context, 0,1,0,1);
CGContextAddRect(context, CGRectMake(0,0,320,480));
CGContextClosePath(context);
CGContextDrawPath(context,kCGPathFill);

CGContextRestoreGState(context);

}

i run it in the simulator, the whole screen becomes green, then i run this on my device, only the quarter of the screen becomes green, in order to make the whole screen green on my device, i have to draw a larger rectangle

  CGContextAddRect(context, CGRectMake(0,0,640,960));

seem like my device has twice resolution than the simulator,
how can i fix this?

© Stack Overflow or respective owner

Related posts about iphone-simulator

Related posts about quartz-2d