【发布时间】:2016-09-11 08:10:26
【问题描述】:
我有一个表格视图,其中一些单元格由 2 个标签填充。
如果存在名为“label1-label2-name”的 mp3 文件,则播放该文件。
NSArray *final;
NSString *element;
final = [NSArray arrayWithObjects: @"a", @"b", @"c", @"d", nil];
现在在我的cellForRowAtIndexPath 中,我正在尝试做同样的事情,但只是在文件存在时显示播放按钮(按钮最初是隐藏的)。
- (CustomCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
for (element in final) {
buttonA = [NSString stringWithFormat:@"%@-%@-AAA-%@", current[indexPath.row][0],current[indexPath.row][1], element];
fileA = [[NSBundle mainBundle] pathForResource:buttonA ofType:@"mp3"];
BOOL fileExistsA = [[NSFileManager defaultManager] fileExistsAtPath:fileA];
if (fileExistsA) {
cell.playA.hidden = false;
}
}
}
这里发生的情况是,即使存在名为“label1-label-2-AAA-a”的文件,如果文件“label1-label-2-AAA-d”不存在,播放按钮将被隐藏.
如何在特定单元格显示/隐藏播放?
【问题讨论】:
标签: ios objective-c uitableview nsfilemanager