开发者

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] bou开发者_开发问答nds];

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:

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


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]];
0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜