方向错误
我的申请中遇到一个问题,这让我很生气。在我的应用程序中,我将模拟器旋转为横向模式,但在下面的函数中,我得到纵向方向。
这里有什么问题呢?请帮帮我。
-(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 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
首先设置方向值是方法
}
现在根据 setTheOrientation 方法中的布尔值设置您需要的坐标值。
First set the orientation value is the method
}
Now set the values of the coordinates which you require according to the boolean values in the setTheOrientation method.
该方法返回 BOOL,您必须返回 YES 或 NO
The method returns BOOL, you have to return either YES or NO
为什么你没有返回 BOOL 值?是或否告诉操作系统您将处理相应的方向事件。
Why you did't return a BOOL value? YES or NO to tell the OS that you're gonna handle corresponding orientation events.
如果您想要纵向模式,请在 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