UIDevice Orientation [英] UIDevice Orientation

查看:140
本文介绍了UIDevice Orientation的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在方法中有以下代码。当我在模拟器中运行它时,调试器跳过代码?我缺少什么?

I have the following code in a method. When I run this in the simulator the debugger skips right over the code?? What am I missing?

if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || 
        ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) 
{       

} else {

}


推荐答案

更新2

这应该没关系,但是尝试打开方向通知:

This shouldn't matter, but try turning on orientation notifications:

[[UIDevice currentDevice] beginGeneratingDeviceOrientationNotifications];


[[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(detectOrientation) name:@"UIDeviceOrientationDidChangeNotification" object:nil];






更新


Update

我的不好,我以为它是空的。

My bad, I assumed it was empty.

尝试删除or语句,然后测试单个方向。看看是否能修复它。也许有一个支架问题或者傻事。

Try removing the or statement and just test for a single orientation. See if that fixes it. Maybe there is a bracket problem or something silly.

我在生产代码中进行了以下测试,所以你的技术应该可行:

I have the following test working in production code, so your technique should work:

    if (([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeLeft) || 
        ([[UIDevice currentDevice] orientation] == UIDeviceOrientationLandscapeRight)) {


}






原始答案


Original Answer

你必须在if块中实际放置语句才能让它进入。

You have to actually put statements in the if blocks to get it to step in.

调试器非常智能,可以跳过空块。

The debugger is smart enough to skip over empty blocks.

这篇关于UIDevice Orientation的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆