- iOS/Objective-C 元类和类别
- objective-c - -1001 错误,当 NSURLSession 通过 httpproxy 和/etc/hosts
- java - 使用网络类获取 url 地址
- ios - 推送通知中不播放声音
我有一个奇怪的问题。我目前正在开发一个邮件应用程序,它曾经随机崩溃而没有错误或在我的控制台中记录。我检查了我的崩溃日志,它显示了低内存警告,并在我的应用程序旁边写了 jettisoned。
所以我怀疑这是一个内存问题,然后回去跟踪我的应用程序的内存使用情况。我使用分配工具来检测整体使用情况,当它的堆大小仅为 4.59 MB 时,我的应用程序崩溃了。
工具指向我正在使用 MBProgressHUD 指标的函数。罪魁祸首是这一行:
[appDelegate showHUDActivityIndicatorOnView:self.parentViewController.view whileExecuting:@selector(refreshInBackground) onTarget:self withObject:nil withText:@"Loading"];
如果我将其替换为[self refreshInBackground]
一切正常,没有问题..
代码如下:
-(void) showHUDActivityIndicatorOnView:(UIView*)view whileExecuting:(SEL)method
onTarget:(id)target withObject:(id)object withText:(NSString*)label{
self.HUD = [[MBProgressHUD alloc] initWithView:view] ;
self.navigationController.navigationItem.hidesBackButton = YES;
[view addSubview:self.HUD];
self.HUD.delegate = nil;
self.HUD.labelText = label;
[self.HUD showWhileExecuting:method onTarget:target withObject:object animated:YES];
}
self.HUD
是一个被保留的属性。
稍作修改的showWhileExecuting
方法如下:
- (void)showWhileExecuting:(SEL)method onTarget:(id)target withObject:(id)object animated:(BOOL)animated {
MyAppdelegate *appDelegate = (MyAppdelegate *)[UIApplication sharedApplication].delegate;
if(!appDelegate.isRequestActive)
{
methodForExecution = method;
targetForExecution = [target retain];
objectForExecution = [object retain];
// Launch execution in new thread
taskInProgress = YES;
[NSThread detachNewThreadSelector:@selector(launchExecution) toTarget:self withObject:nil];
// Show HUD view
[self show:animated];
}
else {
[self done];
}
}
目前我已经从我的应用程序中删除了它并且它现在工作正常并且即使使用 20 - 30 MB 堆内存也不会崩溃。
我不是在这里寻找具体的答案或解决方案。我正在寻找调试方法/调试问题的技术,以便我可以了解导致我的应用程序崩溃的原因。
是不是内存溢出了。如果是这样,那么我现在如何使用 20-30 MB。如果这不是内存问题,为什么我的崩溃报告程序会在我的应用程序名称旁边显示 jettisoned 。
罪魁祸首行 ([appDelegate showHUDActivityIndicatorOnView:self.parentViewController.view whileExecuting:@selector(refreshInBackground) onTarget:self withObject:nil withText:@"Loading"])
每次当我调用这个函数时,一些内存都会增加,因为一些元素被缓存了。但是当内存达到 4.5 MB 时......这条线导致它崩溃
如何找到此问题的根本原因。我如何弄清楚为什么 iOS 正在杀死我的应用程序,我的应用程序旁边写着被抛弃的原因
如有任何帮助或建议,我们将不胜感激。
最佳答案
好的。问题是我在我的 View 中添加了 HUD 进度条[view addSubview:self.HUD]
;
我忘记在它的委托(delegate)方法中将它从 super View 中移除:
- (void)hudWasHidden:(MBProgressHUD *)hud
{
// Remove HUD from screen when the HUD was hidded
[HUD removeFromSuperview]; // app crashes at 4.59 MB if you comment this
[HUD release];
HUD = nil;
}
因为每次在一个 UIView 上添加几个 View ......我猜每个 UIView 顶部的 subview 数量有一个上限......苹果应该在他们的文档中提到这一点......
关于iphone - 由于内存问题/MBProgressHUD 指示器导致应用程序崩溃,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11068254/
仅当我在我的设备(iPhone 6 和 5s)上构建时才会出现此错误。今天当我安装 Firebase/Core 时,它随机弹出。从那以后我就把它删除了。不过,它在模拟器上运行良好。谁能帮我解决一下
我是 iOS 开发的新手,我想运行这个项目 https://github.com/google/uribeacon/tree/master/ios-uribeacon我认为它应该开箱即用。我尝试构建并
有人使用 MBProgressHUD 吗?我想在 MBProgressHUD librairie 提供的示例中使用动画 showWithLabelMixed。我将此代码从示例复制到我的项目中。 -(I
MBProgressHUD 遇到了一点问题。我有一个 WebView ,想要在加载数据时显示 HUD。HUD 出现,但只停留了几秒钟,然后就消失了,但 Web View 尚未完成加载。 -(void)
我使用了我喜欢的 SVProgressHUD,但它不支持方向更改。我正在使用 MBProgressHUD,但它是模态 HUD。 有什么好的替代方案吗?我需要 HUD 是非模态的,并且需要支持方向变化。
在我移动到下一个 View Controller 之前,我想显示 MBProcessHUD 5 秒钟。这是当前的实现 -(void)login { MBProgressHUD *hud = [
我在 AppDelegate 文件中的应用程序中实现 MBProgresshud -(void)showProgressHUD:(NSString*)msg{ if(mbProcess!=nil &&
在我的应用程序中,我正在加载一个资源繁重的 View ,加载大约需要 1 到 2 秒。所以我将它加载到一个单独的线程中,如下所示: hud = [[MBProgressHUD alloc] init]
我在使 MBProgressHUDModeDeterminateHorizontalBar 样式正常工作时遇到一些问题 在 Swift 上还没有找到太多东西。 到目前为止,我已经尝试创建一个将 M
我遇到了一个非常好的 API MBProgressHUD ,但是当我阅读标题中的文档时 MBProgressHUD.h我很困惑,因为文档说 - (id)initWithWindow:(UIWindow
我正在使用 MBProgressHUD 和 STTwitter...我调用 MBProgressHUD,然后从主线程加载 twitter 提要,然后隐藏 HUD。不幸的是,HUD 在收到响应后立即隐藏
我想制作一个“可重用”的 MBProgressHUD。例如,我有一个代码主要是这样的。 - (void)viewDidLoad { HUD = [[MBProgressHUD alloc] i
我有一个场景,我的应用程序仅在第一次下载大量数据,并且这种情况发生在 ViewController1 中。我使用不同的类来下载数据,使用另一个类来保存数据。所以我的问题是,如何更新在 ViewCont
有没有办法让 MBProgressHud 仅在一个选项卡中处于事件状态?目前,由于它在最高 View 中运行,选项卡和 UI 的其余部分没有响应。 最佳答案 是的,有 - 只需将其添加到该选项卡的 R
所以我使用 MBProgressHUD 来加载 View 。我能够让 MBProgressHUDModeIndeterminate 工作并显示它正在加载。但是,每当我尝试使用任何其他类型(例如 MBP
美好的一天! 从网络下载全尺寸图像时,我使用这两个库。 代码: -(void)viewDidAppear:(BOOL)animated { dispatch_async(dispatch_ge
所以我已经实现了 MBProgressHUD 但我想做的是用这行代码调用 MakePost 方法,它是 bool 值,如果正确发布的方法返回 YES 如果不是 NO [HUD showWhileExe
有没有办法像 UIAlertController 那样用窗帘遮住整个屏幕来呈现 MBProgressHUD? 这是 UIAlertController 的样子: 另一方面,这是 MBProgressH
我正在使用这个 api 来分享图片,但是它崩溃了很多次!!!我的代码运行良好,但有时 MBProgressHUD 会导致应用程序崩溃,我是否正确使用了此 API? - (void)shareOther
我正在使用 MBProgressHUD 向用户显示提示,但它没有显示。有许多使用相同方法的viewcontroller。只有一页显示不出来,这个view controller是用xib创建的。方法如下
我是一名优秀的程序员,十分优秀!