villaneo.blogg.se

Didselectpost swift share extension
Didselectpost swift share extension






didselectpost swift share extension

Dismiss the keyboard before it has had a chance to show up:Ĭom.org.SAMPLE.$(PRODUCT_NAME:rfc1034identifier) ( void ) keyboardWillShow: ( NSNotification * ) note addObserver: self selector: keyboardWillShow: ) name: UIKeyboardWillShowNotification object: nil ] Subscribe to the notification which will tell us when the keyboard is about to pop up: ( void ) didMoveToParentViewController: ( UIViewController * ) parent Make it transparent, so we don't see it, but first remember how transparent it was originally: This is called at the point where the Post dialog is about to be shown. ( void ) willMoveToParentViewController: ( UIViewController * ) parent To add configuration options via table cells at the bottom of the sheet, return an array of SLComposeSheetConfigurationItem here. Comment out this whole function if you want the Post dialog to show. Now let the Host app know we are done, so that it unblocks its UI: NSString *className = ( NSClassFromString( className ) ) and the paths to the photos you want to share: this will use the custom url scheme of your app ( void ) invokeApp: ( NSString * ) invokeArgs If we have reached the last attachment, it's time to hand control to the app: Now add the path to the list of arguments we'll pass to the app: so we temporary copy them to a folder which both the extension and the app can access: The app won't be able to access the images by path directly in the Camera Roll folder, NSLog( was an error retrieving the attachments: error ) [ itemProvider loadItemForTypeIdentifier: ( NSString * ) kUTTypeImageĬompletionHandler: ^ ( UIImage * image, NSError * error ) Managing lifeycle from a Share Extension should be done in the didSelectCancel and didSelectPost methods which are the delegate methods called when the. M_inputItemCount = įor ( NSItemProvider * itemProvider in item.attachments ) Reset the counter and the argument list for invoking the app:

didselectpost swift share extension

Note that we aren't using massively unique names for the files in this example: NSString * documentsPath = containerURL.path NSURL * containerURL = containerURLForSecurityApplicationGroupIdentifier: APP_SHARE_GROUP ] NSData * jpegData = UIImageJPEGRepresentation( image, 1.0 ) ( NSString * ) saveImageToAppGroupFolder: ( UIImage * ) image It will be a comma-separated list of file paths: /path/to/image1.jpg,/path/to/image2.jpg The list of arguments we will pass to the AIR app when we invoke it. ( void ) addImagePathToArgumentList: ( NSString * ) imagePath

didselectpost swift share extension

We'll tell the Host we are done after we've invoked the app. Note: This call is expected to be made here. Do validation of contentText and/or NSExtensionContext attachments here NSString * APP_SHARE_GROUP = NSString * APP_SHARE_URL_SCHEME = m_oldAlpha = 1.0 // Keeps the original transparency of the Post dialog for when we want to hide it. NSString * m_invokeArgs = NULL // A string to be passed to your AIR app with information about the attachments. NSUInteger m_inputItemCount = 0 // Keeps track of the number of attachments we have opened asynchronously. #define ShareViewController ShareViewController Macro to hide post dialog or not, if defined, will be hidden, comment during debugging 私のSHAREEXTENSIONには #import "ShareViewController.h" だから私のメインアプリケーションデリゲートには - (BOOL)application:(UIApplication *)application openURL:(NSURL *)url sourceApplication:(NSString *)sourceApplication annotation:(id)annotation NSLog( "Attachments Count: %d ", inputItem.

didselectpost swift share extension

Note: Alternatively you could call super's -didSelectPost, which will similarly complete the extension context. Inform the host that we're done, so it un-blocks its UI. Do the upload of contentText and/or NSExtensionContext attachments. This is called after the user selects Post.








Didselectpost swift share extension