iOS 8 - Disable iCloud Photo Sharing Activity - ios

Apparently iOS8 by default adds a "iCloud Photo Sharing" activity to activity views in iOS8 and I haven't found any useful documentation regarding it, especially how to explicitly remove it (going into the "More" option allows the user to toggle showing/hiding it, but for our app we want to completely disallow this option).
Has anyone figured anything out about how to disable this? Any input would be appreciated. Thanks!

If you init your UIActivityViewController with full of images, iCloud sharing set to activity types by default. You can add a string in your activityItems array. This move will cause that iCloud sharing to be removed from activityTypes.
NSArray *Items = [NSArray arrayWithObjects: image1, image2, #"", nil];
UIActivityViewController *activityViewController = [[UIActivityViewController alloc] initWithActivityItems:Items applicationActivities:nil];

Normally you'd set the excludedActivityTypes property on your UIActivityViewController instance -- e.g., to exclude posting to Facebook, you'd put UIActivityTypePostToFacebook in that array.
But it doesn't look like the Built-in Activity Types list (either in the documentation or in UIActiviy.h) includes a constant for iCloud Photos. That's probably worth filing a bug about.

Related

How to add an app icon to the IOS native share?

I added the ability to share information from my app, but the native share menu presents this white default icon next to the "text to share" instead of my app icon.
This is the code I used to show the share window -
NSString* nsTitle = UTF8_TO_PSTR(title);
NSArray* activities = #[nsTitle];
UIActivityViewController* sharingController = [[UIActivityViewController alloc] initWithActivityItems:activities applicationActivities:nil];
[navigationController presentViewController:sharingController animated:YES completion:nil];
How can I add my app icon to the share window?
I already have some icons in the AppIcon.appiconset folder, but it doesn't use them.

UIDocumentMenuViewController / UIDocumentPickerViewController slow to show in view

I am trying to use the iOS file picker to select text files but when I instantiate and present (modally) a UIDocumentMenuViewController or a UIDocumentPickerViewController the UI takes a while to show up.
This is the code I tried to use for the UIDocumentMenuViewController the one for the UIDocumentPickerViewController would be fairly similar:
UIDocumentMenuViewController *menuVC = [[UIDocumentMenuViewController alloc] initWithDocumentTypes:#[(NSString *)kUTTypeText] inMode:UIDocumentPickerModeOpen];
menuVC.delegate = self;
[self presentViewController:menuVC animated:YES completion:nil];
If I try to call this code 3 or more times then the lag disappears.
I understand that when working with iCloud documents there are synchronous operations that takes time but I didn't find a way to kind of preload that so by the time I present the view controller it happens instantly. I even tried to instantiate the view controllers much before presenting them, but the initialisation doesn't seam to be the bottleneck.
Did anyone experienced the same problem?
It turns out the problem was related to using appearance on a UISegmentController with a custom Font. It may be related to other UIKit controls as well.
Here the way I reproduced it on a clean project:
NSDictionary *attributes = #{NSFontAttributeName: [UIFont fontWithName:#"Pacifico" size:16]};
[[UISegmentedControl appearance] setTitleTextAttributes:attributes forState:UIControlStateNormal];
I filed a radar. Please go and dupe, especially if you find this is affected by other appearance calls.

UIActivityViewController, activities not being completed, sharing options not loading

I have an app that has a share button. This share button loads a UIActivityViewController for sharing to Facebook, Twitter, email, text message, etc.
It used to work fine, and I think it still works fine on the simulator, but on devices, the view controller appears with all the right options, and if you click on one, either nothing happens, or if it's Mail, the mail modal view loads and then dismisses itself. Then I get my log "Activity was not performed.", which is when the completion block returns false for completed but the activityType was not null. So it is recognizing the selection, but it isn't loading the activity into the view for some reason
I have checked the stuff I'm trying to share, even replaced it with dummy stuff (as shown below), still no luck. I am using a normal device, I have my Twitter, Mail, and Facebook accounts set up, texting works too. The only thing that works is copy (i.e. when you copy the share contents to the clipboard). In other apps on the same device, the UIActivityViewController and the loading of selected activities works just fine. Same issue observed on other devices running the app as well.
Really don't understand what the issue is here. Very perplexing! Any help or suggestions of things to try would be much appreciated. I don't see any way to debug this issue.
Here's the code: (note I tried removing the image as well, no luck)
- (void)shareTapped {
NSString *shareText = #"Testing";//[self shareText];
NSURL *url = [NSURL URLWithString:#"http://www.google.ca"]; //[self shareURL];
NSArray *activityItems = [NSArray arrayWithObjects:shareText,url, self.shareImage, nil];
UIActivityViewController *shareDrawer = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
shareDrawer.excludedActivityTypes = #[UIActivityTypePostToWeibo,UIActivityTypeAssignToContact,UIActivityTypeSaveToCameraRoll,UIActivityTypePrint];
shareDrawer.completionHandler = ^(NSString *activityType, BOOL completed) {
if (completed) {
NSLog(#"Selected activity was performed.");
} else {
if (activityType == NULL) {
NSLog(#"User dismissed the view controller without making a selection.");
} else {
NSLog(#"Activity was not performed.");
}
}
NSString *result = completed ? #"success" : #"fail";
if (activityType == NULL) {
result = #"dismissed";
}
};
[self presentViewController:shareDrawer animated:YES completion:nil];
}
OK, by process of elimination I finally narrowed down the culprit:
I have a custom UISegmentedControl with a custom font for the text and I manually adjusted the content offset to make it appear properly. Although I have removed these lines and the segmented control actually looks fine.
Here's the code (I've confirmed that it's all three lines that cause the problem)
[[UISegmentedControl appearance] setContentPositionAdjustment:UIOffsetMake(4, 0) forSegmentType:UISegmentedControlSegmentLeft barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setContentPositionAdjustment:UIOffsetMake(0, 0) forSegmentType:UISegmentedControlSegmentCenter barMetrics:UIBarMetricsDefault];
[[UISegmentedControl appearance] setContentPositionAdjustment:UIOffsetMake(-4, 0) forSegmentType:UISegmentedControlSegmentRight barMetrics:UIBarMetricsDefault];
Now, seeing as the views that popup after you select a share option DO NOT HAVE SEGMENTED CONTROLS in them, I have no clue why this would cause this problem. But it definitely works now that I removed it.
Thanks for those of you who attempted to help. Of course, there's no way you could have possibly guessed this was the issue. Chances are pretty low that anyone would ever encounter this problem in the first place, since adjusting the content position is probably fairly rare.
To debug this issue I followed the following steps:
I tested if the issue had something to do with the properties on the UIActivityViewController that I was setting, or the activity items I was sharing. It did not.
I tested if UIActivityViewController worked properly when called from a different view controller inside my app. It did not.
I made a blank view controller with a button that causes a generic UIActivityViewController to show on press of a bar button. I made that my root view. That worked, thus showing that it was an isolated issue.
Instead of making that view controller the root of my app, I pushed it from my normal main view. It no longer worked, thus determining that the problem probably had something to do with my main view.
I commented out all the code in viewDidLoad, viewDidAppear, and viewWillAppear, except for adding a button to the nav bar which would load my sharing test. That worked. Then I uncommented viweDidAppear and viewWillAppear, still worked. So I uncommented chunks of viewDidLoad until I figured out exactly what the problem was.
What I learned: For weird problems like this (i.e. ones that seem like an iOS bug or something, but you can't find anyone posting about it), you should spend more time debugging before trying to post to stack overflow.
(I should really know this by now, but every new problem to debug feels like an exception to this rule)
Please comment below if you know why adjusting the content position of UISegmentedControl would mess up the sharing from UIActivityViewController even though those views don't contain segmented controls
Thanks
Had same issue too, here's what I done to overcome it.
I'd recommend adding the Social.framework to your Link Binary and using
SLComposeViewController *socialShare = [SLComposeViewController composeViewControllerForServiceType:shareType];
Where the shareType can be SLServiceTypeFacebook or SLServiceTypeTwitter.
I created a UIAlertview pop-up to show the share options for the user
UIAlertView *social = [[UIAlertView alloc]initWithTitle:#"Share" message:nil delegate:self cancelButtonTitle:#"Cancel" otherButtonTitles:#"Twitter", #"Facebook", #"Email", nil];
and depending on which one they picked (using the UIAlertview Delegate methods) then the content can be shared accordingly, and it's a great alternative to UIActivityViewController.
Hope this suggestion helps, cheers, Jim.

UIActivityViewController with ugly header

I use a UIActivityViewController with valid activities in the activityItems (NSArray).
UIActivityViewController* activityController=[[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
[self presentViewController:activityController animated:YES completion:nil];
I have a problem with the appearance of the UIActivityViewController both in the simulator and on the iPhone itself. If I click 'Mail' then a mail form pops up that displays its title 'New message' directly over the statusbar (can't show you a picture 'cause I lack 'reputation'?) ending up with text written over info in the status bar.
The same happens with the message-activity. I think that the things I do are pretty basic and don't even offer the opportunity to mess things up. So what can be the reason that this happens? Or better: how can I prevent this from happening?
(Screenshot of the problem.)
Simple solution what worked for me is to embed view in Navigation Controller.
If you are using Storyboard you can try this.

Using Apple icons with iOS 6

With the release of iOS 6 I'd like to revisit the original question here: Access to Apple's built in Icons?
For example, when you hit the 'action' button to share a photo, now instead of an action sheet with buttons titled 'Message', 'Mail', etc., now there is a collection view of the icons for mail, messaging, facebook, twitter, etc.
For a 'share' action in my app I'd like to be able to present the same - because it looks better and would provide a consistent user experience. Is the use of these icons still not allowed, even if they are referring to (and would take the user to) the apps they originally belong to?
For just showing the share UI with icons, you probably want UIActivityViewController.
NSString* someText = self.textView.text;
NSArray* dataToShare = #[someText]; // ...or whatever pieces of data you want to share.
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:dataToShare
applicationActivities:nil];
[self presentViewController:activityViewController animated:YES completion:^{}];
It looks like:
Documentation here.
The problem with using UIActivity for sending mail is that you cannot set the subject field's text, recipients, etc. like you can with MFMailComposeViewController
I've been trying to do a workaround to set the subject field, but have not found a solution yet.
UIActivity class provides built-in activity types for mail, messaging, ...

Resources