UIActivityViewController – is there a way to know which activity was selected?

You can use Activity Types in setCompletionHandler UIActivityViewController *activityVC = [[UIActivityViewController alloc]initWithActivityItems:activityItems applicationActivities:nil]; [activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) { if([activityType isEqualToString: UIActivityTypeMail]){ NSLog(@”Mail”); } if([activityType isEqualToString: UIActivityTypePostToFacebook]){ NSLog(@”Facebook”); } }]; [self presentViewController:activityVC animated:TRUE completion:nil]; Built-in activity types for which the system has built-in support for. NSString *const UIActivityTypePostToFacebook; NSString *const UIActivityTypePostToTwitter; NSString *const UIActivityTypePostToWeibo; NSString … Read more

I have REAL misunderstanding with MFMailComposeViewController in Swift (iOS8) in Simulator

* * IMPORTANT – DO NOT USE THE SIMULATOR FOR THIS. * * Even in 2016, the simulators very simply do not support sending mail from apps. Indeed, the simulators simply do not have mail clients. But! Do see the message at the bottom! Henri has given the total answer. You MUST — allocate and … Read more

How to exclude Notes and Reminders apps from the UIActivityViewController?

If you don’t want to subclass UIActivityViewController you can include them in your .excludedActivityTypes when creating your UIActivityViewController. Objective C: UIActivityViewController *activityController = [[UIActivityViewController alloc]initWithActivityItems:sharingItems applicationActivities:nil]; activityController.excludedActivityTypes = @[ UIActivityTypeAssignToContact, UIActivityTypePrint, UIActivityTypeAddToReadingList, UIActivityTypeSaveToCameraRoll, UIActivityTypeOpenInIBooks, @”com.apple.mobilenotes.SharingExtension”, @”com.apple.reminders.RemindersEditorExtension” ]; [self presentViewController:activityController animated:YES completion:nil]; Swift 4.2: let activityController = UIActivityViewController(activityItems: sharingItems, applicationActivities: nil) activityController.excludedActivityTypes = [ UIActivity.ActivityType.assignToContact, UIActivity.ActivityType.print, … Read more

How can I create a custom UIActivity in iOS?

First, create the files. I chose to name mine ActivityViewCustomActivity Make ActivityViewCustomActivity.h look like this: #import <UIKit/UIKit.h> @interface ActivityViewCustomActivity : UIActivity @end Make ActivityViewCustomActivity.m look like this: #import “ActivityViewCustomActivity.h” @implementation ActivityViewCustomActivity – (NSString *)activityType { return @”yourappname.Review.App”; } – (NSString *)activityTitle { return @”Review App”; } – (UIImage *)activityImage { // Note: These images need … Read more

Cannot set text color of Send and Cancel buttons in the mail composer when presented from the UIActivityViewController in iOS7

Managed to change the text color of the Send and Cancel buttons, which are on the UINavigationBar in the MFMailComposerViewController (both Send and Cancel) and MFMessageComposeViewController (only Cancel), when presented from UIActivityViewController. Using an UIActivityViewController, tap on Messageor Mail: You’ll notice that the default text color of the Send and Cancel buttons is blue: In … Read more

How to set a mail Subject in UIActivityViewController?

Check below code for the email for setting up your email subject: UIActivityViewController* avc = [[UIActivityViewController alloc] initWithActivityItems:@[@”Your String to share”] applicationActivities:nil]; [avc setValue:@”Your email Subject” forKey:@”subject”]; avc.completionHandler = ^(NSString *activityType, BOOL completed) { // … }; Here the line [avc setValue:@”Your email Subject” forKey:@”subject”]; Makes the subject as “Your email Subject” if user picks … Read more

SwiftUI – Half modal?

In Swift 5.5 iOS 15+ and Mac Catalyst 15+ there is a There is a new solution with adaptiveSheetPresentationController https://developer.apple.com/documentation/uikit/uipopoverpresentationcontroller/3810055-adaptivesheetpresentationcontrol?changes=__4 @available(iOS 15.0, *) struct CustomSheetParentView: View { @State private var isPresented = false var body: some View { VStack{ Button(“present sheet”, action: { isPresented.toggle() }).adaptiveSheet(isPresented: $isPresented, detents: [.medium()], smallestUndimmedDetentIdentifier: .large){ Rectangle() .frame(maxWidth: .infinity, maxHeight: .infinity, … Read more

Basic example for sharing text or image with UIActivityViewController in Swift

UIActivityViewController Example Project Set up your storyboard with two buttons and hook them up to your view controller (see code below). Add an image to your Assets.xcassets. I called mine “lion”. Code import UIKit class ViewController: UIViewController { // share text @IBAction func shareTextButton(_ sender: UIButton) { // text to share let text = “This … Read more

UIActivityViewController crashing on iOS 8 iPads

On iPad the activity view controller will be displayed as a popover using the new UIPopoverPresentationController, it requires that you specify an anchor point for the presentation of the popover using one of the three following properties: barButtonItem sourceView sourceRect In order to specify the anchor point you will need to obtain a reference to … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)