views:

100

answers:

1

I know that I'm either operating with a fundamental misunderstanding or have just missed something simple here. Basically I'm trying to add a new UIViewController on top of an existing UIViewController when the user clicks a UIButton.

-(void)newCharacterClick:(id)sender{
    characterViewController *viewController = [[[characterViewController alloc] initWithNibName:@"characterView" bundle:[NSBundle mainBundle]]autorelease];
    //viewController.view.bounds = CGRectMake(0.0, 0.0, 480, 320);
    viewController.view.transform = CGAffineTransformIdentity;
    viewController.view.transform = CGAffineTransformMakeRotation(degreesToRadian(90));
    [[[UIApplication sharedApplication] keyWindow] addSubview:viewController.view];
}

The result looks like can be see here: http://files.me.com/kevin%5Fbeck/5x4b6h

The newly added view appears to be originating around (-20, -20) and exposing the original view to the bottom right. I've tried changing the values of my CGRectMake and the subview doesn't respond (i.e. move to the new coordinates) at all. I've tried adding the subview to [self view] with similar results. It seems like the subview is being added to some subview in my first view, but I'm having trouble finding it. Any suggestions where I can start looking for possible solutions here?

+1  A: 

Looks like you are adding the view to a window, not a view controller?

mahboudz
Exactly! I love when it's as simple as that. Here's what the line should have read.viewController.view.frame = CGRectMake(0.0, 0.0, 320, 480);
Kevin Beck