Ios 来自qml插件的传感器手势不工作

Ios 来自qml插件的传感器手势不工作,ios,qt,qml,qt5,qtquick2,Ios,Qt,Qml,Qt5,Qtquick2,我正在跟踪以检测手机的抖动。这是iOS应用程序开发的一部分 import QtQuick 2.0 import QtQuick.Layouts 1.1 import QtMultimedia 5.0 import QtGraphicalEffects 1.0 import QtSensors 5.0 as Sensors SceneBase { id: screen ///*** Code of Interest ***/// Sensors.SensorGesture {

我正在跟踪以检测手机的抖动。这是iOS应用程序开发的一部分

import QtQuick 2.0
import QtQuick.Layouts 1.1
import QtMultimedia 5.0
import QtGraphicalEffects 1.0
import QtSensors 5.0 as Sensors

SceneBase {
    id: screen

///*** Code of Interest ***///

    Sensors.SensorGesture {
        id: sensorGesture
        enabled: true
        gestures : ["QtSensors.shake"]

        onDetected: {
          console.log("phone shake detected")
        }
    }

/// ************************* ///

    Sensors.Gyroscope {
        id: gyro
        dataRate: 10
        active: true

        onReadingChanged: {
            if (reading.y > 1100){
                console.log("rapid motion detected")
            }
        }
    }

    //... bunch of other code
}
当注释掉与
传感器有关的代码时,所有其他
传感器
工作正常。传感器手势
。但是,如果代码未注释,则会出现以下错误

Could not load  QtQuick2Plugin(0x146a5b80)
Could not load  QtQuick2WindowPlugin(0x146a7df0)
Could not load  QMultimediaDeclarativeModule(0x146a4020)
Could not load  QtQuickLayoutsPlugin(0x146a8120)
Could not load  QtSensorsDeclarativeModule(0x146aa6d0)
Could not load  QtQuickControlsPlugin(0x146aa870)
Could not load  QQmlLocalStoragePlugin(0x146aa9c0)
Could not load  QtQuick2ParticlesPlugin(0x146aa9e0)
Could not load  AVFServicePlugin(0x146aabf0)
Could not load  AVFMediaPlayerServicePlugin(0x146aac20)
Could not load  AudioCaptureServicePlugin(0x145a83e0)
Could not load  CoreAudioPlugin(0x145a9410)
Could not load  QM3uPlaylistPlugin(0x145a7ff0)

Could not load  QDDSPlugin(0x145a8ae0)
Could not load  QICNSPlugin(0x145a92c0)
Could not load  QICOPlugin(0x145a8760)
Could not load  QJp2Plugin(0x145a8a50)
Could not load  QMngPlugin(0x145a8e60)
Could not load  QTgaPlugin(0x145a8f30)
Could not load  QTiffPlugin(0x145a8fb0)
Could not load  QWbmpPlugin(0x145a9320)
Could not load  genericSensorPlugin(0x145a8da0)
Could not load  IOSSensorPlugin(0x145a8e30)
Could not load  QtQuick2Plugin(0x146a5b80)
Could not load  QTcpServerConnection(0x145a82e0)
Could not load  QGenericEnginePlugin(0x145a87f0)
Could not load  QSQLiteDriverPlugin(0x145a8970)
Could not load  QIOSIntegrationPlugin(0x14539070)

请帮助我。

从5.13开始,Qt for iOS不支持传感器手势

请参阅兼容性映射:

我设法用这个扩展名解决了这个问题,该扩展名链接到一个.mm文件中的Qt应用程序:

#import "UIKit/UIKit.h" @implementation UIWindow (WoboqWindow) extern void sendShakeDetectedToRootObject(); - (void)motionEnded:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"motionEnded %@", event); if (motion == UIEventSubtypeMotionShake ) { NSLog(@"Shake it!"); sendShakeDetctedToRootObject(); } } - (void)motionBegan:(UIEventSubtype)motion withEvent:(UIEvent *)event { NSLog(@"motionBegan %@", event); } @end #导入“UIKit/UIKit.h” @实现UIWindow(WoboqWindow) extern void sendshakedDetectedToRootObject(); -(void)motionEnded:(UIEventSubtype)运动 withEvent:(UIEvent*)事件{ NSLog(@“motionEnded%@”,事件); 如果(运动==UIEventSubjectMotionShake) { NSLog(@“摇晃它!”); SendShakeDectedToRoToObject(); } } -(void)运动开始:(UIEventSubtype)带有事件的运动:(UIEvent*)事件 { NSLog(@“运动开始%@”,事件); } @结束 使用此main.cpp:

void sendShakeDetectedToRootObject() { QMetaObject::invokeMethod(rootObject, "shakeDetected"); } void sendshakedDetectedToRootObject(){ QMetaObject::invokeMethod(rootObject,“shakeDetected”); }
从QML引擎获得的rootObject。

您同时解决了这个问题吗?