Graph not following orientation

Posted by user1214037 on Stack Overflow See other posts from Stack Overflow or by user1214037
Published on 2012-03-22T12:27:06Z Indexed on 2012/04/08 5:28 UTC
Read the original article Hit count: 123

Filed under:
|
|
|
|

so I am trying to draw some grid lines that in landscape go all the way down to the bottom, however when I switch to landscape the the graph doesn't follow and the grid lines go smaller.

I have set the

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
{
    // Return YES for supported orientations
    return YES;
}

However it still doesn't work, here is my code. Can anyone spot the problem? this is the custom view file, the view controller is the default apart from the code above that returns yes.

.h file

#import <UIKit/UIKit.h>
#define kGraphHeight 300
#define kDefaultGraphWidth 900
#define kOffsetX 10
#define kStepX 50
#define kGraphBottom 300
#define kGraphTop 0

@interface GraphView : UIView

@end

And here is the implementation

- (void)drawRect:(CGRect)rect
{
    CGContextRef context = UIGraphicsGetCurrentContext();

    CGContextSetLineWidth(context, 0.6);
    CGContextSetStrokeColorWithColor(context, [[UIColor lightGrayColor] CGColor]);

    // How many lines?
    int howMany = (kDefaultGraphWidth - kOffsetX) / kStepX;
    // Here the lines go
    for (int i = 0; i < howMany; i++)
    {
        CGContextMoveToPoint(context, kOffsetX + i * kStepX, kGraphTop);
        CGContextAddLineToPoint(context, kOffsetX + i * kStepX, kGraphBottom);
    }

    CGContextStrokePath(context);

}

Any help would be appreciated

btw I am following this tutorial

http://buildmobile.com/creating-a-graph-with-quartz-2d/#fbid=YDPLqDHZ_9X

© Stack Overflow or respective owner

Related posts about iphone

Related posts about objective-c