方向错误

发布于 2024-10-09 13:12:57 字数 447 浏览 0 评论 0原文

我的申请中遇到一个问题,这让我很生气。在我的应用程序中,我将模拟器旋转为横向模式,但在下面的函数中,我得到纵向方向。

这里有什么问题呢?请帮帮我。

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
  if ( interfaceOrientation == UIInterfaceOrientationPortrait || 
  interfaceOrientation ==    UIInterfaceOrientationPortraitUpsideDown )
  {
    NSLog(@" portrait orientation");
  }
  else
  {
    NSLog(@"Landscape"); 
  }
 return YES;
}

I am having an issue in my application which drives me mad. In my application, I rotate the simulator to the landscape mode, but in my below function, I get portrait orientation.

What is the problem here? Please help me out.

-(BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation 
{
  if ( interfaceOrientation == UIInterfaceOrientationPortrait || 
  interfaceOrientation ==    UIInterfaceOrientationPortraitUpsideDown )
  {
    NSLog(@" portrait orientation");
  }
  else
  {
    NSLog(@"Landscape"); 
  }
 return YES;
}

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

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

发布评论

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

评论(4

心病无药医 2024-10-16 13:12:57

首先设置方向值是方法

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
NSLog(@"shouldAutorotateToInterfaceOrientation called...");
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) 
        defaultOrientation = 0;
    else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
        defaultOrientation = 1;
    [self setTheOrientation];
    return YES;

}

现在根据 setTheOrientation 方法中的布尔值设置您需要的坐标值。

First set the orientation value is the method

- (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation {
// Overriden to allow any orientation.
NSLog(@"shouldAutorotateToInterfaceOrientation called...");
if (interfaceOrientation == UIInterfaceOrientationPortrait || interfaceOrientation == UIDeviceOrientationPortraitUpsideDown) 
        defaultOrientation = 0;
    else if(interfaceOrientation == UIInterfaceOrientationLandscapeLeft || interfaceOrientation == UIInterfaceOrientationLandscapeRight)
        defaultOrientation = 1;
    [self setTheOrientation];
    return YES;

}

Now set the values of the coordinates which you require according to the boolean values in the setTheOrientation method.

眼眸里的快感 2024-10-16 13:12:57

该方法返回 BOOL,您必须返回 YES 或 NO

The method returns BOOL, you have to return either YES or NO

枯叶蝶 2024-10-16 13:12:57

为什么你没有返回 BOOL 值?是或否告诉操作系统您将处理相应的方向事件。

Why you did't return a BOOL value? YES or NO to tell the OS that you're gonna handle corresponding orientation events.

土豪 2024-10-16 13:12:57

如果您想要纵向模式,请在 if clouse 中添加 return TRUE,如果您想要横向模式,则在 else clouse 中添加 return TRUE,如果您想要两种模式,则只需在中键入 return TRUE shouldAutoRotate 循环

If you want portrait mode then add return TRUE in if clouse and If you want landscape then add return TRUE in else clouse and if you want both mode then just type return TRUE in shouldAutoRotate clouse

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