gpt4 book ai didi

ios - MBProgressHUD ,多次崩溃

转载 作者:行者123 更新时间:2023-11-28 22:14:04 26 4
gpt4 key购买 nike

我正在使用这个 api 来分享图片,但是它崩溃了很多次!!!我的代码运行良好,但有时 MBProgressHUD 会导致应用程序崩溃,我是否正确使用了此 API?

- (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;
}

最佳答案

我是这样用的:

[MBProgressHUD showHUDAddedTo: self.view animated: YES];
[self doVeryLongTask];
[MBProgressHUD hideHUDForView: self.view animated: YES];

关于ios - MBProgressHUD ,多次崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22203115/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com