我正在尝试使用新的 iOS6 UIActivityViewController,它工作正常,除了 Memory Leaks 仪器说每次我尝试显示控制器时 NSArray *execludedActivities 都会泄漏。
请注意,我尝试使用一个名为 excludeActivities 的 NSArray,然后将 shareShareController.excludedActivityTypes 设置为以后能够将数组设置为 nil (下面的所有注释代码),但现在我直接设置属性并且仍然存在泄漏.
- (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];
}