0

The iPhone Application Programming Guide shows an example labelled "Listing 2-1 Creating a window with views" (see below). This shows how to create and add two subviews to a window.

I am using a similar pattern=. This works correctly, both windows get displayed.

The problem I am having is to get it to recognize and do rotation. I have added the shouldAutorotateInterfaceOrientation methods to do a return YES. These are being seen. But only one of the views gets rotated.

More specifically the last view to be added gets rotated and the previous one does not. I can get either to rotate by having it as the second addsubview. But cannot get both to rotate. (Testing in the Iphone simulator.)

Any suggestions on what is needed to get both views to rotate correctly?

Here is Apples sample code.

- (void)applicationDidFinishLaunching:(UIApplication *)application {
    // Create the window object and assign it to the
    // window instance variable of the application delegate.
    window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
    window.backgroundColor = [UIColor whiteColor];

    // Create a simple red square
    CGRect redFrame = CGRectMake(10, 10, 100, 100);
    UIView *redView = [[UIView alloc] initWithFrame:redFrame];
    redView.backgroundColor = [UIColor redColor];

    // Create a simple blue square
    CGRect blueFrame = CGRectMake(10, 150, 100, 100);
    UIView *blueView = [[UIView alloc] initWithFrame:blueFrame];
    blueView.backgroundColor = [UIColor blueColor];

    // Add the square views to the window
    [window addSubview:redView];
    [window addSubview:blueView];

    // Once added to the window, release the views to avoid the
    // extra retain count on each of them.
    [redView release];
    [blueView release];

    // Show the window.
    [window makeKeyAndVisible];
}

1 Answer 1

0

This question was abandoned, sadly... I would love to find the answer to that, as it causes alot of problems on the iPad SDK... adding more than 1 subview at a forced landscape mode, will only make one rotated view. Causing alot of confusion, something is very wrong with the system. ~ Natan.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.