iphone - No options in UIDocumentInteractionController -


is possible check how many applications available on device able handle particular file type? basically, have button in application allows users open-in application, don't want show if there no possible applications open document in.

okay, figured out ugly ugly hack, seemed work... love find better way.

create header file extension:

//  uidocumentinteractioncontroller+willshowopenin.h  #import <foundation/foundation.h>  @interface uidocumentinteractioncontroller (willshowopenin) - (bool)willshowopenin; + (bool)willshowopeninforurl:(nsurl *)filepathurl; @end 

and implement:

//  uidocumentinteractioncontroller+willshowopenin.m  #import "uidocumentinteractioncontroller+willshowopenin.h"  @implementation uidocumentinteractioncontroller (willshowopenin) - (bool)willshowopenin {     id <uidocumentinteractioncontrollerdelegate> olddelegate = self.delegate;     self.delegate = nil;     uiwindow *window = [[[uiapplication sharedapplication] windows] objectatindex:0];     if([self presentopeninmenufromrect:window.bounds inview:window                            animated:no])     {         [self dismissmenuanimated:no];         self.delegate = olddelegate;         return yes;     }     else {         self.delegate = olddelegate;         return no;     } }  + (bool)willshowopeninforurl:(nsurl *)filepathurl {     uidocumentinteractioncontroller *tempcontroller = [uidocumentinteractioncontroller interactioncontrollerwithurl:filepathurl];     return [tempcontroller willshowopenin]; } @end 

then use:

#import "uidocumentinteractioncontroller+willshowopenin.h" 

...

nsurl *testurl = [nsurl fileurlwithpath:[[nsbundle mainbundle] pathforresource:@"test" oftype:@"txt"]]; nslog(@"will show - %@",[uidocumentinteractioncontroller willshowopeninforurl:testurl] ? @"yes" : @"no"); 

please tell me there better way :)


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -