当前位置: 动力学知识库 > 问答 > 编程问答 >

iphone - OpenFlow: how to set the frame to show properly in landscape mode?

问题描述:

I'm trying to use the AFOpenFlowView in landscape mode, but I get a black stripe as if the frame was set not go over the status bar or, better, not over the frame where the status bar is in portrait mode.

Here's the code I'm using:

CGRect applicationFrame = [[UIScreen mainScreen] bounds];

AFOpenFlowView *af = [[AFOpenFlowView alloc] initWithFrame:CGRectMake(0, 0, applicationFrame.size.height, applicationFrame.size.width)];

[af setBackgroundColor:[UIColor whiteColor]];

NSString *imageName;

for (int i = 0; i < 9; i++) {

imageName = [[NSString alloc] initWithFormat:@"picture_%d.png", i];

[af setImage:[UIImage imageNamed:imageName] forIndex:i];

[imageName release];

}

[af setNumberOfImages:9];

[af setViewDelegate:self];

[self setView:af];

[af release];

Here's an image to show what happens:

网友答案:

The applicationFrame.size.height will give you the height minus the status bar. It does no take in consideration that your phone is in landscape mode.

Just add the size as 480 x 300.

Can you try the following debug statement:

NSLog(@"Af frame: &@", NSStringFromCGRect(af.frame));
NSLog(@"Application frame: %@",NSStringFromCGRect(applicationFrame));
网友答案:

I'm extremely sorry for taking your time. At the end I found out what the solution was: I was initializing the window with the application frame, i.e.

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] applicationFrame]];

instead of using the right code

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
分享给朋友:
您可能感兴趣的文章:
随机阅读: