iOS: HowTo send SIGNAL when Controller ends preview


  • Qt Champions 2016

    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


  • Qt Champions 2016

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

    thx


  • administrators

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


  • Qt Champions 2016

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


  • Lifetime Qt Champion

    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


  • Qt Champions 2016

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


  • Qt Champions 2016

    @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.


  • Lifetime Qt Champion

    I'd be happy to review it.


  • Qt Champions 2016

    @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.


  • Lifetime Qt Champion

    Might be a job for QTemporaryFile ?


  • Qt Champions 2016

    @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.


  • Qt Champions 2016

    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


Log in to reply
 

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