MPVolumeView 出现在其他单元格中
我正在使用下面的代码在单元格中实现体积视图。
[[cell detailTextLabel] setText: @""];
MPVolumeView *systemVolumeSlider = [[MPVolumeView alloc] initWithFrame: CGRectMake(100, 10, 200, 100)];
[cell addSubview: systemVolumeSlider];
[self.view addSubview:cell];
[systemVolumeSlider release];
//[MPVolumeView release];
但是我有一个问题。每当我在表格视图中向上或向下滚动时,MPVolumeView 也会添加到其他一些单元格中。我该如何解决这个问题?
i am using the code below to implement a volume view into a cell.
[[cell detailTextLabel] setText: @""];
MPVolumeView *systemVolumeSlider = [[MPVolumeView alloc] initWithFrame: CGRectMake(100, 10, 200, 100)];
[cell addSubview: systemVolumeSlider];
[self.view addSubview:cell];
[systemVolumeSlider release];
//[MPVolumeView release];
However I have a problem with it. Whenever i scroll up or down in the tableview the MPVolumeView will be added to some other cells aswell. How could I fix this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正如评论中提到的,带有音量控件的单元格可能会被非音量单元格重新使用,因此如果它已经存在,则需要将其删除。如何做到这一点的一个示例:
在您的评论中,似乎音量控制应该只位于第 8 部分的第二行,因此示例就是这样编写的。根据需要修改。
As mentioned in the comments, the cell with the Volume control may get re-used for non-Volume cells so it needs to be removed if it already exists. An example of how this can be done:
In your comments, it seems the volume control should only be on the 2nd row of the 8th section so the example is written that way. Modify as needed.