FileDialog on iOS only works in portrait mode. Crashes otherwise.



  • If I set FileDialog's folder to shortcuts.pictures when the app is in landscape mode, it flips to portrait mode before showing the OS builtin image picker. If the app is set to only use Landscape mode, Qt crashes:

    MyApp[808:282060] *** Terminating app due to uncaught exception 'UIApplicationInvalidInterfaceOrientation', reason: 'Supported orientations has no common orientation with the application, and [PUUIAlbumListViewController shouldAutorotate] is returning YES'
    

    Is this a bug or am I missing something?


  • Lifetime Qt Champion

    Hi,

    Can you provide a minimal compilable example that shows that behavior ?



  • @SGaist Just create anything using Qt Creator's wizard:

    main.cpp

    #include <QGuiApplication>
    #include <QQmlApplicationEngine>
    
    int main(int argc, char *argv[])
    {
        QGuiApplication app(argc, argv);
        QQmlApplicationEngine engine;
        engine.load(QUrl(QStringLiteral("qrc:/main.qml")));
        return app.exec();
    }
    

    main.qml

    import QtQuick 2.7
    import QtQuick.Window 2.2
    import QtQuick.Dialogs  1.2
    import QtQuick.Controls 1.3
    
    Window {
        visible: true
        width: 640
        height: 480
        title: qsTr("Hello World")
        FileDialog {
            id:             filePicker
            title:          "Please choose an image file"
            folder:         shortcuts.pictures
            visible:        false
            nameFilters:    [ "Image files (*.jpg *.png)", "All files (*)" ]
            onAccepted: {
                console.log("You picked: " + filePicker.fileUrl()
                filePicker.close()
            }
        }
        Button {
            anchors.centerIn: parent
            text: "Pick An Image"
            onClicked: {
                filePicker.open()
            }
        }
    }
    

    Note that you need to add some keys to the .plist file. Either through Xcode or creating your own .plist and adding to your .pro file.

    	<key>NSPhotoLibraryUsageDescription</key>
    	<string>Foo Bar</string>
    	<key>UISupportedInterfaceOrientations</key>
    	<array>
    		<string>UIInterfaceOrientationLandscapeLeft</string>
    		<string>UIInterfaceOrientationLandscapeRight</string>
    	</array>
    

    Everything using the latest version (Qt Creator 4.1.0, Qt 5.7, Xcode 8.0, etc.)


  • Lifetime Qt Champion

    Sorry, I couldn't test.

    Since there has been new releases in between can you check with them ? 5.7.1 is out and 5.8 Beta also.


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.