OpenFlow:如何设置框架以横向模式正确显示?

时间:2011-05-24 10:05:59

标签: iphone coverflow

我正在尝试在横向模式下使用AFOpenFlowView,但是我得到一个黑色条纹,好像框架设置没有超过状态栏,或者更好,而不是在状态栏处于纵向模式的框架上。

这是我正在使用的代码:

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

这是一张图片来展示会发生什么: enter image description here

2 个答案:

答案 0 :(得分:0)

applicationFrame.size.height会给你高度减去状态栏。 它没有考虑到您的手机处于横向模式。

只需将尺寸添加为480 x 300。

您可以尝试以下调试语句:

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

答案 1 :(得分:0)

我非常抱歉花时间。最后我发现了解决方案:我正在用应用程序框架初始化窗口,即

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

而不是使用正确的代码

window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
相关问题