无法仅旋转一个视图

发布于 2024-12-29 02:10:31 字数 579 浏览 2 评论 0原文

我正在使用 XCode 4.2(带有情节提要)

我试图仅旋转其中一个视图(而不是所有视图),但它似乎不起作用...要么没有视图被旋转,要么

我拥有 所有视图检查了摘要中所有支持的视图,并在信息中确保应用程序“支持的界面方向”都存在于

与视图相关的类中,我编写了旋转此特定视图的函数:

-(BOOL) shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation{
return(interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown||
interfaceOrientation != UIInterfaceOrientationPortrait||
interfaceOrientation != UIInterfaceOrientationLandscapeRight||
interfaceOrientation != UIInterfaceOrientationLandscapeLeft)
}

但仍然没有当我旋转屏幕时旋转...任何线索?

i am using XCode 4.2 (with storyboards)

I am trying to rotate only one of the views (and not all the views) but it doesn t seem to be working... either non of the views get rotated or all of them

I have checked all the supported views in the summary , and in info I made sure that the application "supported interface orientations" are all there

in the class that is related to the view I wrote the function to rotate this specific view :

-(BOOL) shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation{
return(interfaceOrientation != UIInterfaceOrientationPortraitUpsideDown||
interfaceOrientation != UIInterfaceOrientationPortrait||
interfaceOrientation != UIInterfaceOrientationLandscapeRight||
interfaceOrientation != UIInterfaceOrientationLandscapeLeft)
}

and still it does not rotate when I rotate the screen ... any clue ?

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

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

发布评论

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

评论(2

惜醉颜 2025-01-05 02:10:31

您的方法可以简化为:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; {
  return YES;
}

您想要做的就是让设备支持所有您想要的方向的方向,然后在特定视图中,使用上面的方法来允许您想要该视图的方向。例如,如果您只需要特定视图的横向模式,您可以使用:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; {
  return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

希望有帮助!

Your method can be reduced to:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; {
  return YES;
}

What you want to do is have the device support orientations in all of the orientations you want, and then in the specific view's, use the above method to allow which orientations you want for that view. So for example, if you wanted only landscape modes for a particular view, you would use:

- (BOOL)shouldAutoRotateToInterfactOrientation:(UIInterfaceOrientation)interfaceOrientation; {
  return UIInterfaceOrientationIsLandscape(interfaceOrientation);
}

Hope that Helps!

笑咖 2025-01-05 02:10:31

在shouldAutorotateToInterfaceOrientation中,您必须返回您想要支持的所有方向。

因此,如果您希望您的应用程序仅以纵向方式工作,请使用以下代码:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

如果您想支持所有可能的方向:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return YES;
    }

In shouldAutorotateToInterfaceOrientation you have to return all the orientations that you want to support.

So if you want your app works just in portrait this is the code to use:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
    return (interfaceOrientation == UIInterfaceOrientationPortrait);
}

If you want to support all possible orientations:

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
        return YES;
    }
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文