Note that there are some explanatory texts on larger screens.

plurals
  1. POiPhone UIDocumentInteractionController presentOpenInMenuFromRect cancel button does not respond
    primarykey
    data
    text
    <p>I am observing a different behavior when "presentOpenInMenuFromRect" is executed in iPhone4 and iPad2 (both running in iOS 4.3.5). In iPad2 it is shown a drop down list, with all the applications that can open a specific file, and it works fine; however, in iPhone4 it is also shown a drop down list (and also works fine), but at the end of the drop down list there is the button "Cancel", which seems to be inactive.</p> <p>In iPad2 this problem does not happen because the button "Cancel" does not appears, only appears the drop down list, and when I tap onto another area different from the drop down list, this list is closed; which is the desired behavior.</p> <p>What I mean saying that the button "Cancel", in iPhone/iPhone4, seems to be inactive is: When I touch it, then nothing happens! Well, to be more specific, if I touch it several times in a short period or time, then, later than sooner, the button "Cancel" seems to respond (it changes its color from gray to blue) and then the drop down list is really closed; which is the desired behavior.</p> <p>I am using the "presentOpenInMenuFromRect" in the following way: I have implemented a "Save" button, which by default is hidden; however, in the method "-(void)webViewDidFinishLoad:(UIWebView *)webView" I detect the "path extension" of the URL, and if it has the ".pdf" extension, then I show the "Save" button; that is:</p> <pre><code>- (void)webViewDidFinishLoad:(UIWebView *)webView { if ([[[myWebViewOL.request.URL.absoluteString pathExtension] lowercaseString] isEqualToString:@"pdf"]) { saveFile0L.hidden = NO; } } </code></pre> <p>And the "action" related to the "save" button (saveFile0L) is the following method "saveFile":</p> <pre><code>[saveFile0L addTarget:self action:@selector(saveFile) forControlEvents:UIControlEventTouchUpInside]; </code></pre> <p>where "saveFile" has the following code:</p> <pre><code>- (void) saveFile { //Do not worry about "FileManager" is only a singleton class //which I have defined in order to implement some common methods //and one of them is "saveFile:(UIWebView*) withUIView:(UIView*) [[FileManager sharedInstance] saveFile:myWebView withUIView:self.view]; } </code></pre> <p>And "saveFile:(UIWebView*)myWebView withUIView:(UIView*)self.view" has the following code:</p> <pre><code>- (void) saveFile:(UIWebView*)webView withUIView:(UIView*)view { NSString* fileName = [[NSFileManager defaultManager] displayNameAtPath:webView.request.URL.absoluteString]; NSURL* fileurl = [NSURL URLWithString:webView.request.URL.absoluteString]; NSData* data = [NSData dataWithContentsOfURL:fileurl]; NSArray* paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES); NSString* docsDirectory = [paths objectAtIndex:0]; NSString* filePath = [docsDirectory stringByAppendingPathComponent:fileName]; [data writeToFile:filePath atomically:YES]; NSURL* url = [NSURL fileURLWithPath:filePath]; //UIDocInteractionController API gets the list of devices that support the file type docController = [UIDocumentInteractionController interactionControllerWithURL:url]; [docController retain]; //Note:[docController presentOpenInMenuFromRect:CGRectZero inView:view animated:YES] //presents a drop down list of the apps that support the file type, //clicking on an item in the list will open that app while passing in the file. //Note: [[UIApplication sharedApplication] canOpenURL:fileurl] //will return YES if there is an app that can handle the specific file BOOL isValid = ([[UIApplication sharedApplication] canOpenURL:fileurl] &amp;&amp; [docController presentOpenInMenuFromRect:CGRectZero inView:view animated:YES]); if (!isValid) { [self showAlertSaveFileError:fileName]; } } </code></pre> <p>At present, I do not know how to make work properly the "Cancel" button which only appears in iPhone (not in the iPad) at the end of the drop down list.</p> <p>Thanks in advance,</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload