0
我使用這個API共享一個圖像,但它崩潰很多次!我的代碼運行良好,但有時MBProgressHUD導致應用程序崩潰,我使用此API是否正確?MBProgressHUD,崩潰很多次
- (void)shareOther {
HUD = [[MBProgressHUD alloc] initWithView:self.view];
[self.view addSubview:HUD];
HUD.delegate = self;
HUD.labelText = @"Loading";
[HUD showWhileExecuting:@selector(capture) onTarget:self withObject:nil animated:YES];
}
- (void)capture {
//capture view
UIGraphicsBeginImageContextWithOptions(Sview.bounds.size, Sview.opaque, 0.0);
[Sview.layer renderInContext:UIGraphicsGetCurrentContext()];
UIImage * screenshot = UIGraphicsGetImageFromCurrentImageContext();
UIGraphicsEndImageContext();
NSString *str = [NSString stringWithFormat:@"some string"];
UIActivityViewController* activityViewController =
[[UIActivityViewController alloc] initWithActivityItems:@[screenshot , str ]
applicationActivities:nil];
UIViewController *vc = self.view.window.rootViewController;
[vc presentViewController: activityViewController animated: YES completion:nil];
}
- (void)hudWasHidden:(MBProgressHUD *)hud {
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview];
HUD = nil;
}
可以粘貼錯誤顯示的應用程序崩潰的時候? – andreamazz
什麼是崩潰? – CW0007007
@ CW0007007 EXC_BAD_ACCESS –