Odd behavior of UIActivityViewController in iOS 7

I used UIActivityViewController with sharing options.

NSURL *url =[NSURL URLWithString:@"google.com"];

UIImage *img = [UIImage imageNamed:@"myImage"];


NSMutableArray *ar2 = [NSMutableArray arrayWithObjects:UIActivityTypePostToWeibo, UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypePrint, UIActivityTypeAssignToContact, nil];

NSArray *itemsToShare =  @[textToShare,url];

UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
[activityVC setValue:@"Sample - Share" forKey:@"subject"];
activityVC.excludedActivityTypes = ar2;
[self presentViewController:activityVC animated:YES completion:NULL];

But it appears with some white look and the name AirDrop as "null". Can anyone suggest me a solution ...enter image description here

+4
source share
1 answer

I have a test code and it works great for me. I am using iPod5 touch and iOS 7.1.2 I have a small suggestion. Try calling with a delay code. as:

[self performSelector:@selector(shareActivityView) withObject:nil afterDelay:0.5];

Your shareActivityView method is as follows:

-(void)shareActivityView
{
    NSURL *url =[NSURL URLWithString:@"google.com"];

    UIImage *img = [UIImage imageNamed:@"myImage"];


    NSMutableArray *ar2 = [NSMutableArray arrayWithObjects:UIActivityTypePostToWeibo,       UIActivityTypeSaveToCameraRoll, UIActivityTypeMessage, UIActivityTypePrint,  UIActivityTypeAssignToContact, nil];

    NSArray *itemsToShare =  @[textToShare,url];

    UIActivityViewController *activityVC = [[UIActivityViewController alloc] initWithActivityItems:itemsToShare applicationActivities:nil];
    [activityVC setValue:@"Sample - Share" forKey:@"subject"];
    activityVC.excludedActivityTypes = ar2;
    [self presentViewController:activityVC animated:YES completion:NULL];
}

This is strange, but sometimes it works.

0
source

Source: https://habr.com/ru/post/1523673/


All Articles