iPhone的方向不正确? [英] Improper iPhone orientation?

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

问题描述

我不知道为什么这不工作。我在写一个游戏,涉及滚动行/列的屏幕周围的块。我的方向严格限制在纵向,但它不会这样的行为。

I can't figure out why this isn't working. I'm writing a game that involves scrolling rows/columns of blocks around the screen. I have my orientation limited strictly to Portrait, but it doesn't behave as so.

当我调用下面的方法,它是从平移的速度。使用日志我可以看到,把我的设备颠倒和平移,就好像我的方向支持人像。

When I call the method below, it is handed the velocity from the pan. Using logs I was able to see that holding my device upside-down and panning around acts as if my orientation supports Portrait. How can I -completely- turn off anything but Portrait?

这里有一些代码可以帮助解释我想做什么,并希望证明我的理智。

Here's some code to help explain what I want to do, and to hopefully justify my sanity.

bool horizontalPan = (fabs(velocity.x) >= (fabs(velocity.y)));
    if (horizontalPan)
    {
        if (fabs(velocity.x) > MAX_VELOCITY)
        {
            if (velocity.x > 0)
                velocity = CGPointMake(MAX_VELOCITY, 0);
            else
                velocity = CGPointMake(-MAX_VELOCITY, 0);
        }
        else
        {
            velocity = CGPointMake(velocity.x, 0);
        }
        velocity = ccpMult(velocity, PAN_SENSITIVITY);
        [self panRow:velocity object:object];
    }
    else
    {
        if (fabs(velocity.y) > MAX_VELOCITY)
        {
            if (velocity.y > 0)
                velocity = CGPointMake(0, MAX_VELOCITY);
            else
                velocity = CGPointMake(0, -MAX_VELOCITY);
        }
        else
        {
            velocity = CGPointMake(0, velocity.y);
        }
        velocity = ccpMult(velocity, PAN_SENSITIVITY);
        [self panColumn:velocity object:object];
    }
}


推荐答案

你是否严格限制肖像'

-(BOOL)shouldAutorotate{
    return NO;
}

这篇关于iPhone的方向不正确?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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