Remove the "Assign to contact" option in the iOS Share Sheet - ios

I have a Share Sheet that shares an image and I want to get rid of the "Add to Contacts" option. How would I go about doing this?

Have a look at the excludedActivityTypes property of the UIActivityViewController. Pass in UIActivityTypeAssignToContact.
UIActivityViewController avc = ... // create the activity view
avc.excludedActivityTypes = #[ UIActivityTypeAssignToContact ];
// now present the activity view controller

Related

How can I implement the feature in my iOS app?

First Image: This view contains 2 navigation bar with tableview. In the second navigation bar, there is one button.
Second and Third Image: When I click on the navigation button (second) one view will appear like this screenshot and according to the selected title will change on navigation.
Again I I select click on the navigation button, again view will appear and when we select an option according to that option tableview will changes.
What is that pop-up view, how to add or show tableview in that view, how to achieve this feature using Objective-C?
The "popup view' in iOS is a UIAlertController: it has two subtypes: alert and action sheet. Then you need actions(those will represent each option in the actionsheet). Add each action to the action sheet then present it. Easy as that. Each action has a block that is executed when the action is selected. No need to show a tableCiew inside the actionsheet, it should stay as close to native as possible to keep the interface familiar to users. Refer to the human interface guidelines for more information.
UIAlertController *actionSheet = [UIAlertController alertControllerWithTitle:#"Title" message:#"Your message here" preferredStyle: UIAlertControllerStyleActionSheet ];
UIAlertAction *action = [UIAlertAction actionWithTitle:#"First item" style:UIAlertActionStyleDefault handler:^(UIAlertAction * _Nonnull action) {
NSLog(#"first item pressed");
}];
[actionSheet addAction:action];
[self presentViewController:actionSheet animated:YES completion:nil];

Prompt use to save to iCloud WITHOUT using UIActivityViewController

If I use the following code
NSArray * activityItems = #[tempFileURL];
UIActivityViewController * activityViewController =
[[UIActivityViewController alloc] initWithActivityItems: activityItems
applicationActivities: nil];
[self.parentViewController presentViewController: activityViewController
animated: YES
completion: nil];
Then choose 'Save to Files', I am presented with the following dialog:
I would like to present this dialog without needing to first go though UIActivityViewController (and the 'save to files' option) first. I haven't been able to find an alternative way to do this. Any suggestions?
Specifically, my question boils down to this:
How can I have a user specify where a file should be saved without going though UIActivityViewController?
I had same issue. And I found a solution.
You can use UIDocumentPickerViewController for that purpose.
// in Your ViewController
let viewController = UIDocumentPickerViewController(urls: [tempFileURL], in: .exportToService)
present(viewController, animated: true)
You can get a screen like the following one.
You can see Apple documentation here.

Facebook UIActivityViewController is Missing the Cancel and Post Buttons

When my app opens the Facebook UIActivityViewController, there is no navigation bar at the top of the Facebook screen and there is no Cancel or Post button - the only way to exit the screen is to kill the app. Other apps that I look at have an additional navigation bar at the top of the Facebook screen, which holds the Cancel and Post buttons.
Here is the code I am using:
NSURL *url = [NSURL URLWithString:#"http://www.mywebsite.com"];
NSArray *activityItems = #[url];
// Put together the UIActivityViewController
UIActivityViewController *activityVC = [[UIActivityViewController alloc]
initWithActivityItems:activityItems
applicationActivities:nil];
activityVC.excludedActivityTypes = #[UIActivityTypePrint,
UIActivityTypeCopyToPasteboard,
UIActivityTypeAssignToContact,
UIActivityTypeSaveToCameraRoll,
UIActivityTypeAirDrop,
UIActivityTypePostToVimeo,
UIActivityTypePostToFlickr,
UIActivityTypeAddToReadingList];
// Present the UIActivityViewController
[self presentViewController:activityVC
animated:YES
completion:nil];
The Twitter, Email, and SMS screens all appear as expected. Facebook is the only one that is having problems.
Some other notes: I notice that when I open the Facebook Share on this app, the status bar turn black with white text. On another test app that I created, the status bar looks grayed-out with black text. Not sure why / what this points to, but might be a clue.
This problem seems to be app-wide, as I have 3 spots where sharing can be invoked, and it is happening in all 3 instances.
Attaching an image. There should be a Navigation bar above the "To: Public" toolbar.
Any ideas would be appreciated.
You can hide the navigation bar as per your requirement.
So, add the below code, if you want to show the navigation when UIActivityViewController is present and then hide it when UIActivityViewController is dismissed:-
//this will be called when the UIActivityViewController will be dismissed, so we are hiding the navigation
[activityVC setCompletionHandler:^(NSString *activityType, BOOL completed) {
[[UINavigationBar appearance] setHidden:YES];
}];
//this will be called when the UIActivityViewController will be shown, so we are enabling the navigation mean unhiding it.
[self presentViewController:activityVC animated:YES completion:^{
[[UINavigationBar appearance] setHidden:NO]
//you can also add code to customize status bar
}];
I have created new app and copy pasted your code on button action. It is workiing perfectly. You can check image of it over here: https://drive.google.com/file/d/0B0FNcjA1N299NWdmZGZQWC1KbzA/view?usp=sharing
As per my knowledge, If you have done something with [UINavigationBar appearance] in your app, then and then only it makes the problem. Please check that.

Show annotation while map view opens

Is ti possible to show an annotation while a map view is opening? I have looked at other pieces of code, but they all involve objectAtIndex, and I am not using a tableview for this selection.
Here is the code I am using to select the view, which is supposed to open when I click a button:
Screen1ViewController
- (IBAction)mapPressed1:(UIButton*)sender
{
mapnew *controller1 = [[[mapnew alloc] initWithNibName:#"mapnew" bundle:nil] autorelease];
controller1.delegate = self;
controller1.modalTransitionStyle = UIModalTransitionStyleFlipHorizontal;
[self presentViewController:controller1 animated:YES completion:nil];
// IS IT POSSIBLE TO DO SOMETHING LIKE THIS INTO THE IBACTION FOR IT TO WORK:
[self.mapView selectAnnotation:NameOfAnnotationForSpecificLocationCoordinates animated:YES];
}
The map that is supposed to open at the click of a button should be able to recognize where the click came from, and open the right annotation. Each point on the map has a name assigned to it.
Any help is appreciated.
Thanks
Asked and answered here: How to open call out MKAnnotationView programmatically? (iPhone, MapKit)
All you need to do is make pass the data to your controller1 so it is ready to show it the moment it appears.

Lack of a close button on UIActivityViewController

I am currently doing some updates for an iOS application. For the update I am going to take advantage of iOS6 capabilities. I am using a UIActivityViewController to get this done as well as some custom UIActivity activities. The main issue I am having is that there is no "Cancel" or "Close" button. The only way you can exit out of the activity view is if you either post something to a social network, or act like you are going to and then cancel.
NSArray* dataToShare = [[NSArray alloc] initWithObjects:#"blah", nil];
// Custom activities are allocated here
NSArray* customActivities = [[NSArray alloc] initWithObjects:activities, nil];
NSArray* excludedActivities = [[NSArray alloc] initWithObjects:exclusions, nil];
activityController = [[UIActivityViewController alloc] initWithActivityItems:formatArray applicationActivities:customActivities];
activityController.excludedActivityTypes = excludedActivities;
activityController.modalPresentationStyle = UIModalPresentationFormSheet;
[[UIApplication sharedApplication].keyWindow addSubview:self.view];
[[UIApplication sharedApplication].keyWindow bringSubviewToFront:activityController.view];
[self presentViewController:activityController animated:YES completion:^{ closureCode
}];
This does everything that I need inside of the activity controller in terms of networking content, I just don't have a close button. I don't know if it is the same issue but when the view disappears if I try to bring one up my "Share" menu again it tells me
<UIActivityViewController: 0x1e0db7d0> on <ShareDelegate: 0x1e048490> which is already presenting <UIActivityViewController: 0x21b1d4f0>
Thoughts? Thanks in advance!
*I am using:
iPad 2
Objective-C/C++
XCode 4.5
iOS6
From the docs for UIActivityViewController (emphasis is mine):
When presenting the view controller, you must do so using the appropriate means for the current device. On iPad, you must present the view controller in a popover. On iPhone and iPod touch, you must present it modally.
On the iPad, the popover will be cancelled by the user tapping outside of the popover.
On the iPhone/iPod touch, the modal view controller will be shown with a cancel button.
In short, don't use a form sheet on the iPad.

Resources