Improper iPhone orientation?

99封情书 提交于 2019-12-13 04:17:26

问题


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];
    }
}

回答1:


How did you 'strictly limit to portrait' did you use

-(BOOL)shouldAutorotate{
    return NO;
}


来源:https://stackoverflow.com/questions/14668685/improper-iphone-orientation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!