Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 08-09-2010, 10:00 AM   #1 (permalink)
Registered Member
 
Join Date: Jul 2010
Posts: 3
SunFish7 is on a distinguished road
Default Architecture help needed -- views / coordinate systems

I am very desperate -- every day I stare at this problem and I cannot get anywhere.

I need to create a large wheel. centre (0, 0), radius 1.0. on the rim of this wheel are several custom-drawn button controls.

a rectangle on the iPhone screen, say (10,10) - (320, 200) can 'see' some fraction of this wheel, say for example (0.5, 0.5) - (0.8, 0.7)

the wheel needs to rotate.

a bit like being able to look through one's bedroom window and seeing part of a fairground wheel as it rotates.

could someone help get me started?

(NOTE: I do not want to use interface builder, Mainly because every visual object will be drawn from code.)

I have created a sub view:

Code:
// Implement loadView to create a view hierarchy programmatically, without using a nib.
- (void)loadView 
{
    [super loadView];

    CGRect frame = CGRectMake(10, 10, 320-10, 200-10);
    
    myView* v = [ [ [myView alloc] initWithFrame:frame] autorelease];
    
    v.clipsToBounds = YES;
    
    [[self view] addSubview: v];
}
And have overridden the drawrect() of myView so that it draws a picture of the wheel ( placing buttons will come later ), and rotates.

Code:
- (void)drawRect:(CGRect)rect {
    // Drawing code
    // Get the graphics context and clear it
    CGContextRef ctx = UIGraphicsGetCurrentContext();
    CGContextClearRect(ctx, rect);
    
    // Draw a red solid square
    //CGContextSetRGBFillColor(ctx, 255, 0, 0, 1);
    //CGContextFillRect(ctx, CGRectMake(10, 10, 50, 50));
    
    CGRect r = CGRectMake(10,10,300,300);
    UIImage* backgroundImage;
    backgroundImage = [UIImage imageNamed:@"Horus2.jpg"];
    [backgroundImage drawInRect:r];
    CGImageRelease(backgroundImage.CGImage);
    
    CGAffineTransform rotate = CGAffineTransformMakeRotation( 45.0 / 180.0 * 3.14 );
    [self setTransform:rotate];

however, this is rotating the actual frame!!! this is no good! I want EVERYTHING to be rotated, not just the image. But I don't want the frame rotated. and I have no idea how to construct the coordinate system I want to work with.

Please could someone help me? I am floundering badly... I have already posted this problem, but wasn't able to understand the reply :/ please please say something I can understand. I cannot move on this project until I have got past this hurdle, and I cannot do it. It is sapping my will to live :/

Sam
SunFish7 is offline   Reply With Quote
Reply

Bookmarks

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 328
9 members and 319 guests
HemiMG, ilmman, iram91419, linkmx, nadav@webtview.com, Objective Zero, Paul Slocum, stanny, v1n2e7t
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,656
Threads: 94,116
Posts: 402,889
Top Poster: BrianSlick (7,990)
Welcome to our newest member, iram91419
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 11:39 PM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0