Code to rotate a view

Discussion in 'iOS Programming' started by RutgerB, Apr 1, 2009.

  1. macrumors newbie

    Joined:
    Jul 13, 2008
    #1
    Hi


    In my application some views support landscape orientation and some don't.
    I have a function to go to another view.

    When I'm in one view that supports landscape and I press a button to go to a view that does not support landscape mode the view should be rotated to portrait. So even when your still holding the iPhone in landscape the view is in portrait.

    What I need is a function that wil rotate the view.


    Thanks
    Rutger
     
  2. macrumors newbie

    Joined:
    Mar 30, 2009
    #2
    You should do a transformation. Try looking at: CGAffineTransformMakeRotation


    Also try googling:uiview rotate
     
  3. macrumors regular

    Joined:
    Oct 3, 2007
    #3
    I have the same problem:

    I have in IB:
    - ViewController
    - UIView1
    - Uiview2

    So, I inserted UIView1 in IB to ViewController like a subview and overrided method:
    PHP:
    -(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return 
    YES;
    }
    UIView1 is show in portrait position correctly.

    When I want to show another view (UIView2) I develop:
    PHP:
    viewController.view view2;
    It shows but not in PORTRAIT view? Why? How to solve this problem?
     
  4. macrumors regular

    Joined:
    Oct 3, 2007
    #4
    I think problem is with the window(UIWindow)

    Because when I wrote:
    PHP:
    viewController.view playfieldView;
    [
    window addSubviewviewController.view];
    [
    window makeKeyAndVisible];
    All is fine. View in horizontal position.

    But if I wrote like this:
    PHP:
    viewController.view mainMenu;
    [
    window addSubviewviewController.view];
        
    viewController.view playfieldView;
    [
    window addSubviewviewController.view];
    [
    window makeKeyAndVisible];
    Then view doesn't rotate ((((
    Why? How to solve this problem?
     

Share This Page