我试图使用新的iOS6的UIActivityViewController,它工作正常,除了内存泄漏仪说,NSArray的* execludedActivities泄漏每次我试图表明控制器时间。
请注意,我试图用一个NSArray称为excludedActivities,然后设置shareShareController.excludedActivityTypes能够设置数组为零后(所有被注释掉下面的代码),但现在我直接设置属性,仍然有泄漏。
- (IBAction)share:(id)sender
{
//prepare the image
UIImage *theImage = [self screenShot];
//The array of activity Items
NSArray *activityItems = [[NSArray alloc] initWithObjects:theImage, nil];
//The acitivyViewController
UIActivityViewController *shareController = [[UIActivityViewController alloc] initWithActivityItems:activityItems applicationActivities:nil];
//Excluded Actvivity Types
//NSArray *excludedAcitivities = [[NSArray alloc] initWithObjects:UIActivityTypeAssignToContact,UIActivityTypeCopyToPasteboard,UIActivityTypePostToWeibo, UIActivityTypePrint, nil];
shareController.excludedActivityTypes = [[NSArray alloc] initWithObjects:UIActivityTypeAssignToContact,UIActivityTypeCopyToPasteboard,UIActivityTypePostToWeibo, UIActivityTypePrint, nil];
//testing fixning the leak of NSArray
//excludedAcitivities = nil;
//set the completion handler
[shareController setCompletionHandler:^(NSString *activityType, BOOL completed) {
//test hiding the By MunasabaPro lable
int shareScreen = pageControl.currentPage;
MainViewController *someController = [viewControllers objectAtIndex:shareScreen];
someController.byLabel.hidden = YES;
}];
[self presentViewController:shareController animated:YES completion:nil];
}