UISlider setValue“泄漏”
嘿希望有人能帮忙,因为我对此束手无策!?
我有一个 UISlider。 我希望它随着任务的进展(播放音乐)而移动。
随着事件的持续发生,我设置了它的值。 (通过轨道的进度)
-(void)updateSlider:(float)value {
NSLog(@" %f ",value);
[timeIndexSlider setValue: value animated:YES];
}
日志表明浮点值很好..
但它只是不动,我得到了无自动释放池 - 只是泄漏消息,您将从控制台中没有自动释放池的线程中获得该消息。 我没有涉及任何线程。
如此频繁地更新 UISlider 是否存在问题?
还有其他方法可以控制滑块的移动吗?
干杯
Hey hope someone can help as I am at my wits end with this!?
I have a UISlider. I would like it to move as progress of a task takes place (playing music).
Im setting its value as the continues events happen. (progress through the track)
-(void)updateSlider:(float)value {
NSLog(@" %f ",value);
[timeIndexSlider setValue: value animated:YES];
}
Logs state that the float value is fine..
but its just doesn't move and I get the no autorelease pool - just leaking message, that you would get from a thread without one in the console. There is no thread involved on my part.
Is there a problem updating a UISlider this often?
Is there another way of controlling the sliders movement?
Cheers
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我认为您正在另一个线程上获取更新,然后在该线程上调用 UIKit。
尝试使用执行更新的新方法执行performSelectorOnMainThread(可能采用 NSNumber 对象)。
I think you're getting updates on another thread and then calling into UIKit on that thread.
Try doing a performSelectorOnMainThread with a new method that does the update (maybe taking an NSNumber object).
您是否保留对 UISlider 的引用? 如果没有,您可能会在 nil 引用上调用 -setValue:animated: 。 Objective-C 将允许这样做,而无需实际执行该方法。
这可能可以解释为什么您将正确的浮点值传递到函数中,但没有获得任何更新...
按照建议设置断点,并确保 UISlider 引用不为零。
如果没有,请尝试发布一些代码以便我们查看。
让我们知道进展如何,
汤姆
Are you retaining a reference to the UISlider? If not, you could be calling -setValue:animated: on a nil reference. Objective-C will allow this, without actually performing the method.
This could potentially explain why you are getting the correct float value passed into the function, but are not getting any updates...
Set a breakpoint as suggested, and make sure that the UISlider reference is not nil.
If not, try posting some code so that we can take a look.
Let us know how it goes,
Tom