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

发布于 2024-11-09 05:34:06 字数 755 浏览 2 评论 0原文

我尝试在横向模式下使用 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];

这是一张显示发生情况的图像: 在此处输入图像描述

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:
enter image description here

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

凹づ凸ル 2024-11-16 05:34:06

applicationFrame.size.height 将为您提供减去状态栏的高度。
它不考虑您的手机处于横向模式。

只需添加大小为 480 x 300。

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

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

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));
离鸿 2024-11-16 05:34:06

非常抱歉耽误您的时间。最后我发现了解决方案是什么:我使用应用程序框架初始化窗口,即而

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

不是使用正确的代码

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

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]];
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文