Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. iOS: HowTo send SIGNAL when Controller ends preview
QtWS25 Last Chance

iOS: HowTo send SIGNAL when Controller ends preview

Scheduled Pinned Locked Moved Solved Mobile and Embedded
sharingios
12 Posts 3 Posters 3.8k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    ekkescorner
    Qt Champions 2016
    wrote on 28 Nov 2017, 06:23 last edited by
    #1

    For my Sharing Example App I have to send a SIGNAL when UIDocumentInteractionController ends preview.

    MyShare.mm:

    void MyShare::sendFile(...) {
        static DocViewController* docViewController = nil;
        ...
        docViewController = [[DocViewController alloc] init];
        [qtUIViewController addChildViewController:docViewController];
        documentInteractionController.delegate = docViewController;
        [documentInteractionController presentPreviewAnimated:YES];
        ...
    }
    // TODO: HowTo call this method from docViewController ?
    void MyShare::handleDocumentPreviewDone() {
    	// send the SIGNAL
    	emit shareFinished();
    }
    

    DocViewController.mm:

    #import "DocViewController.h"
    @interface DocViewController ()
    @end
    @implementation DocViewController
    #pragma mark -
    #pragma mark View Life Cycle
    - (void)viewDidLoad {
        [super viewDidLoad];
    }
    #pragma mark -
    #pragma mark Document Interaction Controller Delegate Methods
    - (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
        #pragma unused (controller)
        return self;
    }
    - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
    {
        #pragma unused (controller)
        // TODO HowTo call handleDocumentPreviewDone() from MyShare ??
        [self removeFromParentViewController];
    }
    @end
    

    I have no Obj-C knowledge, it's even hard to 'read' the syntax - that's why I'm not developing native for iOS and using Qt ;-)
    any ideas what to do ?
    it's the very last step before I'll make my Sharing Example App for Android and iOS public.
    thx

    ekke ... Qt Champion 2016 | 2024 ... mobile business apps
    5.15 --> 6.8 https://t1p.de/ekkeChecklist
    QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

    E 1 Reply Last reply 28 Nov 2017, 16:52
    0
    • E Offline
      E Offline
      ekkescorner
      Qt Champions 2016
      wrote on 1 Dec 2017, 13:18 last edited by
      #12

      here's the Blog: http://blog.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app/
      thx to all helping me with this

      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
      5.15 --> 6.8 https://t1p.de/ekkeChecklist
      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

      1 Reply Last reply
      1
      • E ekkescorner
        28 Nov 2017, 06:23

        For my Sharing Example App I have to send a SIGNAL when UIDocumentInteractionController ends preview.

        MyShare.mm:

        void MyShare::sendFile(...) {
            static DocViewController* docViewController = nil;
            ...
            docViewController = [[DocViewController alloc] init];
            [qtUIViewController addChildViewController:docViewController];
            documentInteractionController.delegate = docViewController;
            [documentInteractionController presentPreviewAnimated:YES];
            ...
        }
        // TODO: HowTo call this method from docViewController ?
        void MyShare::handleDocumentPreviewDone() {
        	// send the SIGNAL
        	emit shareFinished();
        }
        

        DocViewController.mm:

        #import "DocViewController.h"
        @interface DocViewController ()
        @end
        @implementation DocViewController
        #pragma mark -
        #pragma mark View Life Cycle
        - (void)viewDidLoad {
            [super viewDidLoad];
        }
        #pragma mark -
        #pragma mark Document Interaction Controller Delegate Methods
        - (UIViewController *) documentInteractionControllerViewControllerForPreview: (UIDocumentInteractionController *) controller {
            #pragma unused (controller)
            return self;
        }
        - (void)documentInteractionControllerDidEndPreview:(UIDocumentInteractionController *)controller
        {
            #pragma unused (controller)
            // TODO HowTo call handleDocumentPreviewDone() from MyShare ??
            [self removeFromParentViewController];
        }
        @end
        

        I have no Obj-C knowledge, it's even hard to 'read' the syntax - that's why I'm not developing native for iOS and using Qt ;-)
        any ideas what to do ?
        it's the very last step before I'll make my Sharing Example App for Android and iOS public.
        thx

        E Offline
        E Offline
        ekkescorner
        Qt Champions 2016
        wrote on 28 Nov 2017, 16:52 last edited by
        #2

        is there anybody out there ...
        ... with some Obj-C knowledge ?

        thx

        ekke ... Qt Champion 2016 | 2024 ... mobile business apps
        5.15 --> 6.8 https://t1p.de/ekkeChecklist
        QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

        T 1 Reply Last reply 28 Nov 2017, 19:36
        0
        • E ekkescorner
          28 Nov 2017, 16:52

          is there anybody out there ...
          ... with some Obj-C knowledge ?

          thx

          T Offline
          T Offline
          tekojo
          wrote on 28 Nov 2017, 19:36 last edited by
          #3

          @ekkescorner did you ask on QtMob yet? (https://qtmob.slack.com/ for those who don't know the place)

          E 1 Reply Last reply 28 Nov 2017, 20:07
          0
          • T tekojo
            28 Nov 2017, 19:36

            @ekkescorner did you ask on QtMob yet? (https://qtmob.slack.com/ for those who don't know the place)

            E Offline
            E Offline
            ekkescorner
            Qt Champions 2016
            wrote on 28 Nov 2017, 20:07 last edited by
            #4

            @tekojo yes, I already asked there some days ago.
            will try Interests list and StackOverFlow

            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
            5.15 --> 6.8 https://t1p.de/ekkeChecklist
            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

            1 Reply Last reply
            0
            • SGaistS Offline
              SGaistS Offline
              SGaist
              Lifetime Qt Champion
              wrote on 28 Nov 2017, 20:10 last edited by
              #5

              Hi,

              Add a custom init function to DocViewController which takes a MyShare object as parameter (e.g. initWithMyShare) then pass it the instance of your object and store it as a local variable. Then just call the method on the object in documentInteractionControllerDidEndPreview.

              You can see an implementation example for the iOS clipboard support class.

              Hope it helps

              Interested in AI ? www.idiap.ch
              Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

              E 2 Replies Last reply 28 Nov 2017, 20:19
              2
              • SGaistS SGaist
                28 Nov 2017, 20:10

                Hi,

                Add a custom init function to DocViewController which takes a MyShare object as parameter (e.g. initWithMyShare) then pass it the instance of your object and store it as a local variable. Then just call the method on the object in documentInteractionControllerDidEndPreview.

                You can see an implementation example for the iOS clipboard support class.

                Hope it helps

                E Offline
                E Offline
                ekkescorner
                Qt Champions 2016
                wrote on 28 Nov 2017, 20:19 last edited by
                #6

                @SGaist thx. will try to figure out the correct syntax ;-)

                ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                5.15 --> 6.8 https://t1p.de/ekkeChecklist
                QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                1 Reply Last reply
                0
                • SGaistS SGaist
                  28 Nov 2017, 20:10

                  Hi,

                  Add a custom init function to DocViewController which takes a MyShare object as parameter (e.g. initWithMyShare) then pass it the instance of your object and store it as a local variable. Then just call the method on the object in documentInteractionControllerDidEndPreview.

                  You can see an implementation example for the iOS clipboard support class.

                  Hope it helps

                  E Offline
                  E Offline
                  ekkescorner
                  Qt Champions 2016
                  wrote on 28 Nov 2017, 21:04 last edited by
                  #7

                  @SGaist thx to your hints I found a way to make it work.
                  I'm writing a blog about the App and perhaps someone can take a look at the code if it's ok.

                  ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                  5.15 --> 6.8 https://t1p.de/ekkeChecklist
                  QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                  1 Reply Last reply
                  0
                  • SGaistS Offline
                    SGaistS Offline
                    SGaist
                    Lifetime Qt Champion
                    wrote on 28 Nov 2017, 21:12 last edited by
                    #8

                    I'd be happy to review it.

                    Interested in AI ? www.idiap.ch
                    Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                    E 1 Reply Last reply 28 Nov 2017, 21:19
                    0
                    • SGaistS SGaist
                      28 Nov 2017, 21:12

                      I'd be happy to review it.

                      E Offline
                      E Offline
                      ekkescorner
                      Qt Champions 2016
                      wrote on 28 Nov 2017, 21:19 last edited by
                      #9

                      @SGaist cool. will let you know when it's public. probably tomorrow.
                      this was the last open topic on iOS.
                      I must know when preview was done, because if sharing a File from App Data Location, the File must be copied to Documents Location to be available for UIDocumentInteractionController. Then when user comes back to the App I must delete the File from Documents location.

                      ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                      5.15 --> 6.8 https://t1p.de/ekkeChecklist
                      QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                      1 Reply Last reply
                      0
                      • SGaistS Offline
                        SGaistS Offline
                        SGaist
                        Lifetime Qt Champion
                        wrote on 28 Nov 2017, 21:38 last edited by
                        #10

                        Might be a job for QTemporaryFile ?

                        Interested in AI ? www.idiap.ch
                        Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                        E 1 Reply Last reply 28 Nov 2017, 21:53
                        0
                        • SGaistS SGaist
                          28 Nov 2017, 21:38

                          Might be a job for QTemporaryFile ?

                          E Offline
                          E Offline
                          ekkescorner
                          Qt Champions 2016
                          wrote on 28 Nov 2017, 21:53 last edited by
                          #11

                          @SGaist I need the origin filename, so I don't think so.
                          BTW: on iOS I must always delete the file from Documents location,
                          on Android if ACTION_VIEW intent I also delete the file,
                          but if ACTION_EDIT then depending from result code I must move File back into origin AppDataLocation or simply delete if Edit was canceled.

                          ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                          5.15 --> 6.8 https://t1p.de/ekkeChecklist
                          QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                          1 Reply Last reply
                          0
                          • E Offline
                            E Offline
                            ekkescorner
                            Qt Champions 2016
                            wrote on 1 Dec 2017, 13:18 last edited by
                            #12

                            here's the Blog: http://blog.qt.io/blog/2017/12/01/sharing-files-android-ios-qt-app/
                            thx to all helping me with this

                            ekke ... Qt Champion 2016 | 2024 ... mobile business apps
                            5.15 --> 6.8 https://t1p.de/ekkeChecklist
                            QMake --> CMake https://t1p.de/ekkeCMakeMobileApps

                            1 Reply Last reply
                            1

                            1/12

                            28 Nov 2017, 06:23

                            • Login

                            • Login or register to search.
                            1 out of 12
                            • First post
                              1/12
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved