【问题标题】:Different Images using Accelerometer in Xcode在 Xcode 中使用加速度计的不同图像
【发布时间】:2012-06-26 22:57:08
【问题描述】:

我正在尝试在 Xcode 4.3.3 中制作一个应用程序,其中当使用加速度计的 z 轴为正时显示一个图像。但是,当 z 轴变为负值时,我希望出现不同的图像。我是初学者,所以如果你能告诉我应该在哪个文件中编写代码,那就太好了。

谢谢!

【问题讨论】:

    标签: iphone xcode image add accelerometer


    【解决方案1】:

    查看以下链接以了解 UIAccelerometer

    http://developer.apple.com/library/ios/#documentation/uikit/reference/UIAccelerometer_Class/Reference/UIAccelerometer.html

    http://homepages.ius.edu/rwisman/C490/html/chapter22.htm

    http://www.edumobile.org/iphone/iphone-programming-tutorials/how-to-use-accelerometer-in-iphone/

    http://www.ifans.com/forums/threads/tutorial-simple-accelerometer-source-code.151394/

    您需要对以下功能进行更改

    - (void)accelerometer:(UIAccelerometer *)accelerometer 
               didAccelerate:(UIAcceleration *)acceleration 
    {
        if(acceleration.z<0) {
           imageview.image = //Display image to be displayed when z is negative
        }
        else {
           imageview.image = //Display image to be displayed when z is positive
        }
    }
    

    【讨论】:

    • 谢谢。我浏览了这些文件,找不到我的问题的答案。甚至可以得到不同的图像吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多