Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>It was my fault; finally I could solve the problem.</p> <p>The mistake was to use "self.view" and passe it as a parameter for the function "presentOpenInMenuFromRect"</p> <p>[docController presentOpenInMenuFromRect:CGRectZero inView:view animated:YES]</p> <p>However, this"view" (self.view) was not be the suitable one to handle the touch events; this mistake could be noticed thanks to the following warning, which was shown in the Xcode console:</p> <pre><code>2011-08-17 18:12:56.389 MyApplication[287:707] Presenting action sheet clipped by its superview. Some controls might not respond to touches. On iPhone try -[UIActionSheet showFromTabBar:] or -[UIActionSheet showFromToolbar:] instead of -[UIActionSheet showInView:]. </code></pre> <p>This message has given to me the clue and I have modified the code in the following way:</p> <p>The new and right code is:</p> <pre><code>- (void) saveFile:(UIWebView*)webView { NSString* fileName = [[NSFileManager defaultManager] displayNameAtPath:webView.request.URL.absoluteString]; #if DEBUG NSLog(@"&lt;%p %@: %s line:%d&gt; File name:%@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __PRETTY_FUNCTION__, __LINE__, fileName); #endif 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]; //Very important, if "retain" is not called, the application crashes //Present 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. BOOL isValid = [docController presentOpenInMenuFromRect:CGRectZero inView:webView animated:YES]; //Using "webView" instead of "self.view" if (!isValid) { [self showAlertSaveFileError:fileName]; //Shows an alert message } } </code></pre> <p>That is, passing to method "presentOpenInMenuFromRect: inView: animated:" the view "webView" (which is a UIWebView), instead of "self.view".</p>
 

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