怎么利用重力感应判断出iphone的方向呢??不明白

解决方案 »

  1.   

    在viewWillAppear中利用self.interfaceOrientation的值就可以了吧 四个方向if ((self.interfaceOrientation == UIInterfaceOrientationPortrait) || (self.interfaceOrientation == UIInterfaceOrientationPortraitUpsideDown))
    {
    ......
    }
    else if ((self.interfaceOrientation == UIInterfaceOrientationLandscapeLeft) || (self.interfaceOrientation == UIInterfaceOrientationLandscapeRight))
    {
    ......
    }
      

  2.   

    这个问题我前些时间也在搞,研究了半天,官方说的基本没用。apple官方说是用UIDevice就能获得,但试后不行。听做过的同事讲,要根据UIAccerser具体类名忘了,做x,y,x三个方向上的重力判断。你可以去找一下。
      

  3.   

    http://blog.csdn.net/ArthurChenJS/archive/2011/04/24/6358511.aspx
    iphone开发之设备方向和角度计算