Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
176 views
in Technique[技术] by (71.8m points)

ios - Add "Edit in Excel" or "Edit photo" extension

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 
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...