13

I checked the latest Dropbox and Excel for iOS. In Dropbox we get an edit button. On click it opens Excel's extension where you can edit the file.

After save, changes are reflected in the Dropbox file too.

I want to add such a button. Also I'd like to add such a button to images to open them in available "photo editing" apps.

How to check if file (image, xls, doc or any other) can be opened to edit?

Code so far:

UIDocumentPickerViewController *documentPicker = [[UIDocumentPickerViewController alloc] initWithURL:url inMode:UIDocumentPickerModeExportToService];
documentPicker.delegate = self;
documentPicker.modalPresentationStyle = UIModalPresentationFormSheet;
[self presentViewController:documentPicker animated:YES completion:nil];

Also tried changing mode to UIDocumentPickerModeMoveToService...

enter image description here

As per apple docs Move a local document. The user selects an external destination. The document picker moves the document; however, you can still access the document as an external document, letting the user edit the document in place.

But I tried all four modes. Did not show excel option.

   UIDocumentPickerModeImport,
   UIDocumentPickerModeOpen,
   UIDocumentPickerModeExportToService,
   UIDocumentPickerModeMoveToService 
luchaninov
  • 6,792
  • 6
  • 60
  • 75
Durgaprasad
  • 1,910
  • 2
  • 25
  • 44
  • Can you please edit your question more in detail, I dint quite get this "How to check if file (image, xls, doc or any other) can be opened to edit? " for example if this is a image file, if the file exists on your device you should be able to open it and edit it , see this link and code :- https://github.com/heitorfr/ios-image-editor – Max Jun 25 '15 at 14:40
  • Hi, Actually if you open dropbox with excel or doc file, you will see a edit option (see photo). This will open that file in excel or doc application. You can edit that file and changes will be saved in dropbox. I thought they do this using extension (Excel and doc app will a editing extension). But it is not the case. Dropbox sends a url to ecel and copy of file, after editing file, Excel uploads it to particular url. Dropbox downloads from there. I don't want this behavior. – Durgaprasad Jun 29 '15 at 06:28
  • Please refer this :- http://stackoverflow.com/questions/3981199/adding-open-in-option-to-ios-app – Max Jun 29 '15 at 09:15
  • Does @Max comment answer your question? If yes please write an answer one of you two, and please mark it as answered – csharpwinphonexaml Aug 20 '15 at 23:22
  • No. that answer is about opening other app files in my app. I want to open my app in MS Excel and MS word, and edit docs and automatically save in my app. But actually MS Excel and MS word has not provided such extension. When we open doc, it creates a copy and we have to send a rest link, where it will upload the edited file, which our app can download. This is not what I want. So untll MS do not provide such extension this question is not answered. – Durgaprasad Aug 21 '15 at 04:55

2 Answers2

1

The only way to communicate with other iOS apps "locally" is using what is called URLSchemes.

This is the documentation to use URLScheme with the MSOffice apps. https://msdn.microsoft.com/en-us/library/office/dn911482.aspx

Answering the specific question:

How to check if file (image, xls, doc or any other) can be opened to edit?

You can use the UIApplication method called canOpenURL to check if the current device responds to a specific URLScheme and if it does, you can call the app to edit you file. The same can be applied to other apps that you want to open. You just need to see if the app have URLScheme support.

Remembering that in iOS 9 you need to add the URLs you want to call during the app life in the Info.plist. Otherwise, the canOpenURL method will always returno NO.

This code illustrates the approach. However, it is to search some navigation apps. Just like tapping a shared friend location in WhatsApp.

https://snipt.net/wallaaa/using-url-schemes/

The result: result of navigation button

Community
  • 1
  • 1
Wallace
  • 504
  • 4
  • 19
0

it's 2017 and iOS 11 and it's still not possible to edit files in place.

Dropbox is using MS Office API to provide http links to download and upload changed document. Direct edit of the file is only possible if FileProvider extension is implemented and file was opened in editor app via document picker (which grants access to the file in sandbox).

Photo editing is allowed because editor is made by Apple (Photos app).

vlaku
  • 1,534
  • 2
  • 14
  • 27