开发者

Problems figuring out landscape frames and bounds

开发者 https://www.devze.com 2023-02-11 01:23 出处:网络
I\'m trying to layout several custom views in a landscape iPad application (made landscape by deleting all but one interface mention in the plist). However, my code currently doesn\'t work as expected

I'm trying to layout several custom views in a landscape iPad application (made landscape by deleting all but one interface mention in the plist). However, my code currently doesn't work as expected;

- (void)viewDidLoad { [super viewDidLoad];

LeftTableViewController *lvc = [[LeftTableViewController al开发者_JAVA技巧loc] initWithNibName:@"LeftTableViewController" bundle:nil];
// Resize this view controller appropriately
lvc.view.frame = CGRectMake(0, 0, 224, 768);
[[self view] addSubview:lvc.view];

ReaderViewController *rvc = [[ReaderViewController alloc] initWithNibName:nil bundle:nil];
// Resize this view controller appropriately
rvc.view.frame = CGRectMake(224, 0, 800, 768);
[[self view] addSubview:rvc.view];</code>

I expected the code above to give me the LeftTableViewController entirely to the left. This appears to work, but I had to remove all the size markers from the nib to get it there. The ReaderViewController should take up the remaining space, but it only takes up about half of the space left. This image illustrates this (the ReaderViewController is the green space, while the application is the purple space).

http://i52.tinypic.com/z7d2.png

I seem to be misunderstanding something crucial about frames and bounds in landscape mode. What coordinates for the frame or bounds should I set for a view to appear as expected and why?


Coordinates are same for both landscape, portrait modes. Portrait is 0,0 (left, top) and 768,1024 (width, height) and 0,0 (left, top) and 1024,768 (width, height) for landscape.

It's quite hard to answer, because we don't see the whole code and your XIB file. You have wrong autoresizing mask probably.

P.S. 768 is not correct height, because you have status bar visible, which has 20 pixels.

0

精彩评论

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

关注公众号