开发者

Question about the orientation of UIView

I have two viewController, A and B.

I want that this app is ju开发者_如何转开发st for Landscape, so in A and B I overwrite

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

There are two ways to init B, and add B's view as a subview of A

1.

In A's viewDidLoad, I get the object of B through init method.

B *bController = [[B alloc] init];
b.view.backgroundColor = [UIColor redColor];
[self.view addSubview:b.view];

2.

In A's viewDidLoad, I get the object of B through initWithNib method. In B's Nib file. I change the orientation of view to LandScape, and change the size of view to (480,300)

When I output the frame of B's view in B's viewDidLoad method, I got different result.

The output of "method 1" is (320,460), although the device was rotated to Landscape and view was full of screen.

The output of "method2" is (480,300).This is just for my expectation.

Why the output of method1 isnt (480,300) but (320,460)?

Thanks!


change the autoSizing property of subView, that's it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜