【发布时间】:2011-07-20 17:36:14
【问题描述】:
- (void) startLoading {
[self blink];
}
- (void) blink {
[UIView animateWithDuration:0.5
delay: 0.0
options: UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionCurveEaseOut
animations:^{
//animate stuff
}
completion:^(BOOL finished){
[self blink];
}];
}
- (void) stopLoading {
//What goes here?
}
在我的 UIView 的initWithFrame 中,我构建了一些加载器图形,然后从[self startLoading] 启动加载器动画。
现在的问题是,我该如何停止这个“无限循环”? 或者 stopLoading 或 dealloc 方法中的哪些内容可以很好地破坏所有内容?
当我忽略存在完成块的事实并从超级视图中释放我的 UIView 时,一切正常几秒钟(超过指定的 0.5 秒)然后应用程序崩溃并显示一条消息:
malloc: * mmap(size=2097152) 失败(错误代码=12) 错误:无法分配区域 ** 在 malloc_error_break 中设置断点进行调试
我在 malloc_error_break 中有一个断点,罪魁祸首是动画块。
我假设 UIView 是通过从超级视图中删除并稍后执行完成块来释放的,引用 self 这是消息释放的对象。
我在文档中找不到有关取消“排队”块的任何内容。
【问题讨论】:
标签: cocoa-touch objective-c-blocks